Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Vbs wait command

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Loops Section Overview
Suggested Courses

916 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