Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Vbs wait command

Posted on 2014-01-15
5
Medium Priority
?
893 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 2000 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

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

661 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