Solved

Vbs wait command

Posted on 2014-01-15
5
828 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 25

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 25

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 25

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

630 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