myITforum.com Community Forum myITforum.com Community Forum

Home  Forums  Blogs  Live Support chat  Search Articles  Wiki  FAQ  Email Lists  Register  Login  My Profile  Inbox  Address Book  My Subscription  My Forums 

Photo Gallery  Member List  Search  Calendars  FAQ  Ticket List  Log Out

All Forums RSS Feed Subscription:


  


Running a MSI within a VBScript

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
  Printable Version
All Forums >> [Scripting Technologies] >> VB Script >> Running a MSI within a VBScript Page: [1]
Login
Message << Older Topic   Newer Topic >>
Running a MSI within a VBScript - 8/5/2008 4:06:56 PM   
jbyers

 

Posts: 7
Score: 0
Joined: 5/19/2006
Status: offline
I am trying to execute a MSI installation that also contains a command line property within a VBScript.  I have always had issues with calling a msi in a vbscript especially one that contains additional parameters or properties.  A example looks similar to the following.   I appreciate any assistance!!

x:\application\version\myapp.msi env=prod /qb!
Post #: 1
RE: Running a MSI within a VBScript - 8/5/2008 4:53:36 PM   
jsandys


Posts: 531
Score: 17
Joined: 3/24/2005
From: San Antonio, TX
Status: offline
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "msiexec.exe /I x:\application\version\myapp.msi env=prod /qb!"

If the path to your msi contains any spaces then add double quotes around it: WshShell.Run "msiexec.exe /I ""x:\application\version\myapp.msi"" env=prod /qb!"

_____________________________

Jason
________________________________________
http://myitforum.com/cs2/blogs/jsandys/default.aspx

(in reply to jbyers)
Post #: 2
RE: Running a MSI within a VBScript - 8/8/2008 10:20:21 AM   
blaird

 

Posts: 7
Score: 0
Joined: 3/13/2006
Status: offline
Below is a sample I use to Uninstall/Reinstall applications:

'On Error Resume Next
'
'  Author:   Brian Laird
'  Utility:  Script to execute an uninstall of an application before
'            completely reinstalling the application
'
'  Application Variables:
'    
'      strAppName         = Used in IE window and prompt to close app.
'      strSWGUID          = HKLM\SW\MS\Win\CV\Uninstall key to check
'      strUninstallString = String to execute uninstall command
'      strInstallString   = String to execute install command
'      strCheckExeMemory  = Name of EXE to check in memory
'
' REMARK - Declare application variables
strAppName         = "MY Application"
strSWGUID          = "{EE990000-AAAA-BBBB-CCCC-EEEE633241F5}"
strUninstallString = "MsiExec.exe /q /x" & strSWGUID
strInstallString   = "msiexec.exe /q ROOTDRIVE=C:\ ALLUSERS=2 /i My_Application.msi"
strCheckExeMemory  = "My Plan Management.exe"
' REMARK - Declare OS and Environment connection variables
Set objShell = CreateObject("WScript.Shell")
strComputer = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
strComputer = uCase(strComputer)
Set objWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objReg = GetObject("winmgmts://" & strComputer & _
   "/root/default:StdRegProv")
' REMARK - Setup IE status window
Set objExplorer = WScript.CreateObject("InternetExplorer.Application")
objExplorer.Navigate "about:blank"  
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width=400
objExplorer.Height = 200
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Document.Title = strAppName & " Reinstaller"
objExplorer.Document.Body.Style.Cursor = "wait"
Do While objExplorer.Busy
   WScript.Sleep 200
Loop
objExplorer.Visible = 1
' REMARK - Check for application in memory
colItemsCount = 1
Do While colItemsCount = 1
   Set colItems = objWMI.ExecQuery _
     ("SELECT * FROM Win32_Process WHERE Name = '" & strCheckExeMemory & "'")
   colItemsCount = colItems.count
   If colItemsCount <> 0 Then
     objExplorer.Document.Body.InnerHTML = "<DIV ALIGN=""center""><P>" _
                                 & "Please close " & strAppName & " application" _
                                 & "</P>" & vbCrLf _
                                 & "<P><INPUT TYPE=""hidden"" ID=""OK"" " _
                                 & "NAME=""OK"" VALUE=""0"">" _
                                 & "<INPUT TYPE=""submit"" VALUE="" OK "" " _
                                 & "OnClick=""VBScript:OK.Value=1""></P></DIV>"
     Do While objExplorer.Document.All.OK.Value = 0
       WScript.Sleep 200
     Loop
   End If
Loop
' REMARK - Get Software Uninstall Registry information
strMessageBody = vbCrlf & vbTab & vbTab & "Checking for previous install"
objExplorer.Document.Body.InnerHTML = strMessageBody
WScript.Sleep 2000
Const HKLM = &H80000002
strSWUninstall = _
   "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & _
   strSWGUID
objReg.GetStringValue HKLM, strSWUninstall, "UninstallString", _
   strReadRegUninstallString
if InStr(strReadRegUninstallString,strSWGUID) Then
   Set objExecObject = objShell.Exec(strUninstallString)
   strMessageBody = vbCrlf & vbTab & vbTab & _
     "Uninstalling previous version - Please Wait"
   objExplorer.Document.Body.InnerHTML = strMessageBody
   Do Until objExecObject.Status = 1
     WScript.Sleep 100
   Loop
End If
' REMARK - Install new version of software
Set objExecObject = objShell.Exec(strInstallString)
strMessageBody = vbCrlf & vbTab & vbTab & _
   "Installing new version - Please Wait"
objExplorer.Document.Body.InnerHTML = strMessageBody
Do Until objExecObject.Status = 1
   WScript.Sleep 100
Loop
' REMARK - Close IE status window
objExplorer.Document.Body.Style.Cursor = "default"
objExplorer.Quit
Wscript.Quit

(in reply to jsandys)
Post #: 3
Page:   [1]
All Forums >> [Scripting Technologies] >> VB Script >> Running a MSI within a VBScript Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts



  
Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.406