Solved

Vbs wait command

Posted on 2014-01-15
5
762 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to open text file 11 131
Passing Credentials into a command line 13 40
Assigning VBA code to a specific worksheet 3 32
Limit the # times a macro code will run 14 51
Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

820 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