andrew_89
asked on
vbscript to install a .msi file
I am trying to come up with a script to install a .msi file on 100+ machines.
I found the below from activexperts.com but keep getting an rpc error. I know it is becuase I am not using correct syntax....
The error is on line 3.. What should be the value for Set objConnection???
Const wbemImpersonationLevelDele gate = 4
Set objWbemLocator = CreateObject("WbemScriptin g.SWbemLoc ator")
Set objConnection = objwbemLocator.ConnectServ er _
("WebServer", "root\cimv2", "fabrikam\administrator", _
"password", , "kerberos:WebServer")
objConnection.Security_.Im personatio nLevel = wbemImpersonationLevelDele gate
Set objSoftware = objConnection.Get("Win32_P roduct")
errReturn = objSoftware.Install("\\atl -dc-02\scr ipts\1561_ lab.msi",, True)
Wscript.Echo errReturn
Thanks for any help
I found the below from activexperts.com but keep getting an rpc error. I know it is becuase I am not using correct syntax....
The error is on line 3.. What should be the value for Set objConnection???
Const wbemImpersonationLevelDele
Set objWbemLocator = CreateObject("WbemScriptin
Set objConnection = objwbemLocator.ConnectServ
("WebServer", "root\cimv2", "fabrikam\administrator", _
"password", , "kerberos:WebServer")
objConnection.Security_.Im
Set objSoftware = objConnection.Get("Win32_P
errReturn = objSoftware.Install("\\atl
Wscript.Echo errReturn
Thanks for any help
ASKER
How does it know where the .msi lives to execute on the remote machine
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks alot that is very helpful !!!!
I was also able to get the first script to work, but it you have to mess around with dcom on the PC sourcing the MSI.
On the MSI source
load dcomcnfg
Expand Component Services\Computers\My computer
Right click My Computer and select properties
Select the COM Security TAB
Select the Edit Defaults of the Access Permissions
Grant System Remote Access.
;new vbs file
strcomputer="some machine"
Const wbemImpersonationLevelDele gate = 3 ;not change to 3 from 4
Set objWbemLocator = CreateObject("WbemScriptin g.SWbemLoc ator")
Set objConnection = objwbemLocator.ConnectServ er (strComputer, "root\cimv2", , , , "kerberos:" & strComputer)
Wscript.Echo "Error: " & Err.Description
objConnection.Security_.Im personatio nLevel = wbemImpersonationLevelDele gate
Set objSoftware = objConnection.Get("Win32_P roduct")
errReturn = objSoftware.Install("\\MSI source\sha re\some.ms i",,True)
WScript.Echo(errReturn)
On the MSI source
load dcomcnfg
Expand Component Services\Computers\My computer
Right click My Computer and select properties
Select the COM Security TAB
Select the Edit Defaults of the Access Permissions
Grant System Remote Access.
;new vbs file
strcomputer="some machine"
Const wbemImpersonationLevelDele
Set objWbemLocator = CreateObject("WbemScriptin
Set objConnection = objwbemLocator.ConnectServ
Wscript.Echo "Error: " & Err.Description
objConnection.Security_.Im
Set objSoftware = objConnection.Get("Win32_P
errReturn = objSoftware.Install("\\MSI
WScript.Echo(errReturn)
http://www.computerperformance.co.uk/vbscript/wmi_process_start.htm#Scenario_-_Why_you_need_to_Launch_a_Processes_on_a_Remote_Machine_
Works like a charm