好的,我是一个C#程序员,正在试图简化自定义Windows窗体应用程序的部署,我inheritance了它,并为WiX构build了一个安装程序(这个应用程序需要定期重新安装,因为我正在对其进行更改)。 我并不习惯pipe理types的东西(或vbs,或WMI,或terminal服务器,或思杰,甚至WiX和MSI不是我通常处理的东西),但到目前为止,我把一些vbs,并有一个最终目标心里。 msi工作,我已经从我的开发机器上映射的O:驱动器安装它,而RDP到一个Citrix机器。
最终目标:部署在我的开发机器上编写的代码,并将其编译到MSI(我可以在WiX范围内以及Windows安装程序引擎允许的范围内进行改进)到我的用户可以访问的Citrix机器群集。
我的脚本中缺lessMSI在远程计算机上执行的操作?
布局:
脚本:
'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,这让我怀疑更改用户/安装命令是否真的工作。
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计算机使用另一个用户帐户(尽pipe相同的域),这就是为什么我使用:
Set objLocator = CreateObject("WbemScripting.SWbemLocator") Set objWMIService = objLocator.ConnectServer( .....
我最终使用了一个基于托尼的input和build议的PowerShell脚本,它看起来更干净。
尽pipe获取Win32_Product类安装方法仍然看起来有些复杂(与WMIC命令相比),但这正是Technet所说的:
http://blogs.msdn.com/b/wmi/archive/2010/01/06/wmic-vs-wmi-powershell-cmdlets.aspx http://technet.microsoft.com/zh-CN/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") }
一个citrix有自己的部署技术,其次是你说你的部署方法在某种程度上失败了? 如果是这样,我希望它是一个模仿问题。 但是我不能从你的解释中知道。
以下是您拥有的所有代码的快捷方式
1
复制file.msi \ citrixservername \ c $ \ pathtoyourfile
wmic / node:citrixservername product call install true,“”,“c:\ PathToYour \ File.msi”
注意安装文件是复制到服务器本地1,如果你不这样做,你会有一个模拟问题!