Solved

Vbs wait command

Posted on 2014-01-15
5
742 Views
Last Modified: 2014-01-16
Hi
I am running a silent install of logmein, at the end of the installation I want to run a command to remove a registry key that the installation creates. However I wondered if there was a way to combine the commands, but ensure the second initiates only once the program has installed.

Code below

Command 1
Set WshShell = WScript.CreateObject("WScript.Shell") 
WshShell.Run "msiexec.exe /q /i C:\Users\Kevin\Desktop\LogMeIn.msi DEPLOYID=00_w6snwu02u19nywfzbfoewcfxkd9zeg0qg0668 INSTALLMETHOD=5 FQDNDESC=1"

Open in new window


Command 2
Const HKEY_LOCAL_MACHINE = &H80000002
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\"
strComputer = "."
strFind = "LogMeInCredProv"

If Right(strKey, 1) = "\" Then strKey = Left(strKey, Len(strKey) - 1)
Set objRegistry = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer & "\root\default:StdRegProv")
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubKeys
If Not IsNull(arrSubKeys) Then
                For Each strSubKey In arrSubKeys
                                strValueName = strKey & "\" & strSubKey & "\"
                                objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strValueName, "", strValueData
                                If strValueData = strFind Then
                                                WScript.Echo "Deleting " & strValueName & " because it has a value of " & strValueData
                                                On Error Resume Next
                                                intReturn = objRegistry.DeleteKey(HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey)
                                                If intReturn = 0 And Err.Number = 0 Then    
                                                                Wscript.Echo strSubKey & " successfully deleted"
                                                Else
                                                    Wscript.Echo "Error deleting " & strSubKey & ". Return code = " & intReturn & ", error = " & Err.Number & ": " & Err.Description
                                                End If
                                                Err.Clear
                                                On Error GoTo 0
                                End If
                Next
End If

Open in new window

0
Comment
Question by:kwatt562
  • 3
  • 2
5 Comments
 
LVL 24

Expert Comment

by:chaau
ID: 39783957
Yes, there is.
Have a look at the parameters for the Run command. You need to add these options:
intWindowStyle
    Optional. Integer value indicating the appearance of the program's window. Note that not all programs make use of this information.

bWaitOnReturn
    Optional. Boolean value indicating whether the script should wait for the program to finish executing before continuing to the next statement in your script. If set to true, script execution halts until the program finishes, and Run returns any error code returned by the program. If set to false (the default), the Run method returns immediately after starting the program, automatically returning 0 (not to be interpreted as an error code).
I recommend you use 1 for intWindowStyle and True for bWaitOnReturn
WshShell.Run "msiexec.exe /q /i C:\Users\Kevin\Desktop\LogMeIn.msi, 1, True

Open in new window

0
 

Author Comment

by:kwatt562
ID: 39784013
thanks but I get the Windows Installer msiexec options screen when I try that
0
 
LVL 24

Accepted Solution

by:
chaau earned 500 total points
ID: 39784047
Sorry, I did not notice that your command line is actually a very big one and spans three lines. Please try this one:
WshShell.Run "msiexec.exe /q /i C:\Users\Kevin\Desktop\LogMeIn.msi DEPLOYID=00_w6snwu02u19nywfzbfoewcfxkd9zeg0qg0668 INSTALLMETHOD=5 FQDNDESC=1", 1, True

Open in new window

0
 
LVL 24

Expert Comment

by:chaau
ID: 39784050
BTW, it is a good idea to put your scripts inside the code blocks. Makes life easier for everyone
0
 

Author Comment

by:kwatt562
ID: 39784097
worked perfectly, thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now