views:

433

answers:

3

Hey SO Gus,
This might seem like a dump question, but my complete ignorance with VbScript is giving me no chance to try to work it out.In short, a system administrator friend of mine, asked me to write him a script that should allow him to enter a remote machine name, a domain credentials, and an MSI package that will be installed on the specified remote machine.
I know this is silly, I mean, come on! No one can just log in to SO and ask for a cake, people should ask about how to get the cake cooked. I know, but please forgive my absolute laziness and help! :)
Thanks in advance.

+1  A: 

Can you use psexec?

Or, it seems you can use the Install method of the WMI Win32_Product class. See technet for more info. There's some more info in this serverwatch article too

Dan F
+2  A: 

TechNet has a sample script: Install Software on a Remote Computer.

Helen
Actually the required script should prompt the user for the domain credentials, the MSI package path, and destination computer. The one you posted doesn't!
Galilyou
And yeah, I can't modify it myself (vbscript dump, remember!)
Galilyou
Maybe it would be a good time to learn?
aphoria
+2  A: 

This will open simple input boxes to get the required information. *NOTE: Input is only checked to make sure it is not blank, entering invalid data will cause the script to fail.

strUser = ""
strPassword = ""
strMSI = ""
strComputer = ""

'Get user name, cannot be blank
Do While strUser = ""
    strUser = InputBox("Enter user name", "User Name")
Loop
'Get password, cannot be blank
Do While strPassword = ""
    strPassword = InputBox("Enter password", "Password")
Loop
'Get msi package path, cannot be blank
Do While strMSI = ""
    strMSI = InputBox("Enter the path to the msi package", "MSI package")
Loop
'Get destination computer, cannot be blank
Do While strComputer = ""
    strComputer = InputBox("Enter the destination computer name", "Computer")
Loop


Const wbemImpersonationLevelDelegate = 4

Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objConnection = objwbemLocator.ConnectServer _
    (strComputer, "root\cimv2", strUser, strPassword)
objConnection.Security_.ImpersonationLevel = wbemImpersonationLevelDelegate

Set objSoftware = objConnection.Get("Win32_Product")
errReturn = objSoftware.Install(strMSI,,True)

** This script is untested.

Tester101