• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1952
  • Last Modified:

VBScript to install MSI

I would like to install MSI package in remote computers using VBscript.
I know that can be done through GPO, but in my case I need to deploy it with VBscript taking all the default settings.


Any help?
0
jskfan
Asked:
jskfan
  • 7
  • 7
  • 2
  • +1
10 Solutions
 
x-menIT super heroCommented:
consider that c:\temp\MyPack.msi exists

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("c:\windows\system32\msiexec.exe /i c:\temp\MyPack.msi")
0
 
kin327Commented:
Hi there. If I understand what you're trying to do correctly, you will need to run the VBscript on each computer in order that the MSI may be installed locally from either a network or local source. That means you've got to a mechanism to distribute the VBscript itself to and run it on each computer. That is why you need a deployment mechanism. You've mentioned GP Deployment, but if that is not an option for you, how about some other free deployment tools available? Check out, for instance PDQ Deploy. You can google it, see if you like it and download the free version!
0
 
Daz_1234Commented:
To expand on x-men's post:

Most msi files accept standard unattended installation switches.  The commands are typically like the below:

Unattended with simple progress bar, installed for all users of the computer, do not automatically restart
msiexec /i "c:\temp\MyPack.msi" ALLUSERS=1 /norestart /qb

Open in new window


Unattended, completely silent, no restart
msiexec /i "c:\temp\MyPack.msi" ALLUSERS=1 /norestart /qn

Open in new window


To initiate this from VBScript, I would use something like the following (note the doubling of the quotes around the path within the string.  This is in case there are spaces in the path):
Dim wshShell, ret

Set wshShell = CreateObject("WScript.Shell")
ret = wshShell.Run("msiexec /i ""c:\temp\MyPack.msi"" ALLUSERS=1 /norestart /qb", 1, True)
MsgBox "Installation finished.  Return code: " & ret

Open in new window


Common return codes you can test for:
0 (zero) - Success
3010 - Success, restart required
1602 - User cancelled installation
1618 - Another installation is in progress (Windows Installer is busy)

More codes here:  http://support.microsoft.com/kb/229683

For deploying without GPO, if the users have permissions to install then the simplest way is to put the msi and the VBScript on a share that every user has read access to.  Then put a line in the logon script to call the VBScript on the network share.
If the users do not have permissions, as is more common, then I would recommend that you use a deployment tool like PDQ Deploy as kin327 posted above if you don't already have something like SCCM or Altiris available to you.

Hope this helps,
Daz.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
jskfanAuthor Commented:
I wantto use the vbscript along with Psexec to deploy MSI remotely
0
 
Daz_1234Commented:
I think this post is exactly what you need:

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24784533.html#25493038

Just change line 11 from:
strScript = "\\server\share\scripttorun.vbs"

Open in new window

... to:
strCmd = "msiexec /i ""\\Server\location\of\msi\MyPack.msi"" ALLUSERS=1 /norestart /qb"

Open in new window

... and change line 23 from:
strCommand = strPSExec & " -accepteula -e -u " & strAdminUser & " -p " & strPassword & " \\" & strComputer & " wscript.exe //B " & strScript

Open in new window

... to:
strCommand = strPSExec & " -accepteula -e -u " & strAdminUser & " -p " & strPassword & " \\" & strComputer &  strCmd

Open in new window


You'll need to populate the a computers.txt text file with the target computers and place it in the same location as the script.  Also change the location of PSexec.exe on line 10.

Good luck
Daz.
0
 
Daz_1234Commented:
Ah, forgot the space.  Line 23 will need to be:
strCommand = strPSExec & " -accepteula -e -u " & strAdminUser & " -p " & strPassword & " \\" & strComputer & " " & strCmd

Open in new window


Regards,
Daz.
0
 
x-menIT super heroCommented:
consider that c:\temp\MyPack.msi exists at destination

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("psexec \\MyRemoteHost c:\windows\system32\msiexec.exe /i c:\temp\MyPack.msi")
0
 
jskfanAuthor Commented:
OOPS.......
it is a .exe file not .msi.

I may need to find an exe to msi packager.
0
 
Daz_1234Commented:
Is this a well known program?  We may be able to help depending on what it is.

Daz.
0
 
jskfanAuthor Commented:
I guess I will first need to package  the cp013888.exe to msi then use a script to deploy it to remote servers.

HPSIM has built-in deployment for the hp management home page, but it s very slow.
0
 
Daz_1234Commented:
If you can find a silent install switch for the HP eye then you could just run that.  I think that if you run that exe you should get a folder with the extracted installation, and hopefully a setup.exe.  

If so, look at this  http://docs.hp.com/en/381372-004/381372-004.pdf page 26 to find out how to install silently.  Once you work out the unattended command line you can use that instead of the msiexec one in the script.

Daz
0
 
jskfanAuthor Commented:
You are correct , when I extracted cp013888.exe, I get the files shown in the attached screenshot among them is setup.exe.

Now how am I going to deploy the script considering the files shown in the screenshot.
HP.jpg
0
 
Daz_1234Commented:
This information based on document: http://docs.hp.com/en/381372-004/381372-004.pdf page 26

1. On a test computer, install it by using this command line:
setup.exe /r

Open in new window

The installation will run but the options you choose are being recorded, so ensure that you choose all the options that you want to be chosen automatically when deploying.

2. Harvest file setup.iss from the Windows directory and put it with all the files in the folder you posted above.

3. Copy all the files, including the setup.iss file to a network share that everyone can access.

4. Get the deployment script from this post:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24784533.html#25493038

5. make the following changes to the script:

Change line 10 from:

strPSExec = "\\server\share\psexec.exe"

... to:
strPSExec = "psexec.exe"

Open in new window

Change line 11 from:

strScript = "\\server\share\scripttorun.vbs"

... to (edit the 2 x paths in the line below to the one you copied the install to in step 3 above) :
strCmd = """\\server\location\of\setup\setup.exe"" /s /f1""\\server\location\of\setup\setup.iss"""

Open in new window

... and change line 23 from:

strCommand = strPSExec & " -accepteula -e -u " & strAdminUser & " -p " & strPassword & " \\" & strComputer & " wscript.exe //B " & strScript

... to:
strCommand = strPSExec & " -accepteula -e -u " & strAdminUser & " -p " & strPassword & " \\" & strComputer & " " & strCmd

Open in new window


6. Put the edited script, psexec.exe, and a text file called computers.txt into a folder on the computer you'll be rolling out from.

7. Add the names of the target computers to the computers.txt

8. Double-click the VBscript to run!

Good luck,
Daz.


0
 
jskfanAuthor Commented:
I followed up the steps described above.
How do I know (watch) that the script is running in the remote computer/
I am logged in to the remote computer but don't see anything.

is there away to rell the script to popup a message if there is any error or if it cannot install the software properly?
0
 
Daz_1234Commented:
Change line 23 to:


strCommand = strPSExec & " -accepteula -e -i -u " & strAdminUser & " -p " & strPassword & " \\" & strComputer & " " & strCmd

Open in new window


... and that will show the installation interactively on the target computer (added -i parameter).

Regards,
Daz.
0
 
jskfanAuthor Commented:
Thanks a lot for your help---
I will try it later.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 7
  • 7
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now