
わかりました。私は C# プログラマーで、WiX でインストーラーを継承して構築したカスタム Windows フォーム アプリの展開を効率化しようとしています (このアプリは、変更を加えるため、定期的に再インストールする必要があります)。管理タイプのもの (または VBS、WMI、ターミナル サーバー、Citrix、WiX や MSI でさえ、普段扱うものではありません) にはあまり慣れていませんが、これまでにいくつかの VBS をまとめて、最終目標を念頭に置いています。MSI は機能し、開発マシンのマップされた O: ドライブからインストールし、Citrix マシンに RDP で接続しました。
最終目標:開発マシンで作成され、MSI にコンパイルされたコード (WiX と Windows インストーラー エンジンで許可される範囲内で改善できるもの) を、ユーザーがアクセスできる Citrix マシンのクラスターに展開します。
MSI をリモート マシンで実行するためのスクリプトに何が欠けているのでしょうか?
レイアウト:
- マシン A は私の開発マシンで、vbs スクリプトと msi ファイル (XP SP3) があります。
- マシン C1 - C6 は、msi (Server 2003 R2 SP2) 経由でアプリケーションをインストールする必要がある Citrix サーバーです。
- オプションで、すべてのマシンがアクセスできる共有ネットワーク リソースもあります。
脚本:
'Set WMI Constants
Const wbemImpersonationLevelImpersonate = 3
Const wbemAuthenticationLevelPktPrivacy = 6
'Set whether this is installing to the debug Citrix Servers
Const isDebug = true
'Set MSI location
'Network location yields error 1619 (This installation package could not be opened.)
msiLocation = "\\255.255.255.255\odrive\Citrix Deployment\Setup.msi"
'Directory on machine A yields error 3 (file not found)
'msiLocation = "C:\Temp\Deploy\Setup.msi"
'Mapped network drive (on both machines) yield error 3 (file not found)
'msiLocation = "O:\Citrix Deployment\Setup.msi"
'Set login information
strDomain = "MyDomain"
Wscript.StdOut.Write "user name:"
strUser = Wscript.StdIn.ReadLine
Set objPassword = CreateObject("ScriptPW.Password")
Wscript.StdOut.Write "password:"
strPassword = objPassword.GetPassword()
'Names of Citrix Servers
Dim citrixServerArray
If isDebug Then
citrixServerArray = array("C4")
Else
'citrixServerArray = array("C1","C2","C3","C5","C6")
End If
'Loop through each Citrix Server
For Each citrixServer in citrixServerArray
'Login to remote computer
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objLocator.ConnectServer(citrixServer, _
"root\cimv2", _
strUser, _
strPassword, _
"MS_409", _
"ntlmdomain:" + strDomain)
'Set Remote Impersonation level
objWMIService.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
objWMIService.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
'Reference to a process on the machine
Dim objProcess : Set objProcess = objWMIService.Get("Win32_Process")
'Change user to install for terminal services
errReturn = objProcess.Create _
("cmd.exe /c change user /install", Null, Null, intProcessID)
WScript.Echo errReturn
'Install MSI here
'Reference to a product on the machine
Set objSoftware = objWMIService.Get("Win32_Product")
'All users set in option parameter, I'm led to believe that the third parameter is actually ignored
'http://www.webmasterkb.com/Uwe/Forum.aspx/vbscript/2433/Installing-programs-with-VbScript
errReturn = objSoftware.Install(msiLocation,"ALLUSERS=2 REBOOT=ReallySuppress",True)
Wscript.Echo errReturn
'Change user back to execute
errReturn = objProcess.Create _
("cmd.exe /c change user /execute", Null, Null, intProcessID)
WScript.Echo errReturn
Next
私もこれを使用してインストールしようとしましたが、エラー コードは返されませんでしたが、msi もインストールされず、change user /install コマンドが実際に機能しているかどうか疑問に思います。
errReturn = objProcess.Create _
("cmd.exe /c msiexec /i ""O:\Citrix Deployment\Setup.msi"" /quiet")
Wscript.Echo errReturn
@tony ファイルは問題なくコピーされますが、次のようなメッセージが表示されます:
ERROR:
Code = 0x80070005
Description = Access is denied.
Facility = Win32
Citrix マシンには別のユーザー アカウント (同じドメイン) を使用する必要があるため、次のアカウントを使用しました。
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objLocator.ConnectServer( .....
最終的に、Tony の入力と提案に基づいて PowerShell スクリプトを使用しましたが、見た目も動作もはるかにきれいになりました。
Win32_Product クラスのインストール メソッドを取得するのは、まだ少し複雑に見えますが (WMIC コマンドと比較すると)、Technet では次のように提案されています。
リンク http://technet.microsoft.com/ja-jp/library/dd347651.aspx より
#$servers = 'C1' , 'C2', 'C3' , 'C5', 'C6'
$servers = , 'C4'
$MyCredential = Get-Credential MyDomain\otherusername
foreach($server in $servers)
{
Copy-Item -LiteralPath C:\Temp\Deploy\Setup.msi -Destination \\$server\c$\Temp\Setup.msi -Force
(Get-WmiObject -ComputerName $server -Credential $MyCredential -List | `
Where-Object -FilterScript {$_.Name -eq "Win32_Product"}).Install("C:\TEMP\Setup.msi")
}
答え1
まず、Citrix には独自の展開テクノロジがあります。次に、展開方法が何らかの形で失敗しているとおっしゃっているのですか? そうであれば、それは偽装の問題であると思われます。しかし、あなたの説明からはよくわかりません。
以下は、すべてのコードへのショートカットです。1
つ目の
コピーは、file.msi \citrixservername\c$\pathtoyourfile です。
wmic /node:citrixservername product call install true,"", "c:\PathToYour\File.msi"
インストール ファイルが最初にサーバーのローカルにコピーされることに注意してください。これを行わないと、偽装の問題が発生します。