I need .vbs that will Check in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ and in HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\ for a key and if it doesn't exists run an installation.
' Core variable definitions ---------------------------------------------------
'
strComputer = "."
Set WshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
objCtx.Add "__ProviderArchitecture", 64
Set objLocator = CreateObject("Wbemscripting.SWbemLocator")
Set objServices = objLocator.ConnectServer("","root\default","","",,,,objCtx)
Set objReg1 = objServices.Get("StdRegProv")
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
'search 64 bit registry Uninstall-----------------------------------------------'
Dim strValue, strKeyPath, arrSubKeys, subkey, isInstalled
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys, subkey
For Each subkey In arrSubKeys
If (subkey = "{DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}") Then 'Microsoft visual C++ 2010 x86 10,0,30319'
isInstalled = "1"
else
If (subkey = "{1D8E6291-B0D5-35EC-8441-6616F567A0F7}") Then 'Microsoft visual C++ 2010 x86 10,0,40219'
isInstalled = "1"
End If
End If
Next
'search 32 bit registry Uninstall------------------------------------------------'
Dim arrSubKeys1, subkey1
strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys1, subkey1
For Each subkey1 In arrSubKeys1
If (subkey1 = "{DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}") Then 'Microsoft visual C++ 2010 x86 10,0,30319'
isInstalled = "1"
else
If (subkey1 = "{1D8E6291-B0D5-35EC-8441-6616F567A0F7}") Then 'Microsoft visual C++ 2010 x86 10,0,40219'
isInstalled = "1"
End If
End If
Next
if isInstalled = 0 Then
Dim WShell
Dim sInstallCommand
Dim sPath, oExecShell, errReturn
Set WShell = CreateObject("WScript.Shell")
Function ExecuteCommandLine (CommandLine)
Set oExecShell = WShell.Exec (CommandLine)
Do While oExecShell.Status = 0: WScript.Sleep 50: Loop
errReturn = oExecShell.ExitCode
ExecuteCommandLine = errReturn
End Function
i'm just testing the .vbs now , I want to deploy it on several computers.
In this phase the script just doesn't stop even though the subkeys exist, it always goes to:
Dim WShell
Dim sInstallCommand
Dim sPath, oExecShell, errReturn
Set WShell = CreateObject("WScript.Shell")
Function ExecuteCommandLine (CommandLine)
Set oExecShell = WShell.Exec (CommandLine)
Do While oExecShell.Status = 0: WScript.Sleep 50: Loop
errReturn = oExecShell.ExitCode
ExecuteCommandLine = errReturn
End Function
Wscript.Quit()
End if
Let me rephrase: The script will be deployed togheter with an aplication (.msi file) and I need this scenario:
- if one of the above reg. keys are present on a computer (ex: {DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}) then stop
- if the above keys are not present on a computer then execute a command line
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.