Hi everyone,
I am wanting to have a VBscript that will check to see if an application is installed. If it is not installed then I want to install it. If it is installed then I want to check the version and see if it is the newest version and if it is not a certain version then lets send the upgrade file to be installed.
This is what I have so far below. It just basically checks to see if it is installed and if it isn't then it installs the 2 .msi files from a batch file. I would love to have them all install from a vbs file, but I have had a hard time getting that to do work since you cannot install 2 .msi files at the same time.
----
Set wshShell = WScript.CreateObject("WSCript.shell")
strOS = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName")
If strOS = "Microsoft Windows XP" or Left(strOS,9) = "Windows 7 Professional" Then
If strOS = "Microsoft Windows XP" Then
'Lets Check for GuardianEdge and see if it is installed. If not, lets install it.
If Not RegKeyExists("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{7EDD1CCA-F75D-4DB2-A958-B2E83C840EAF}") Then
wshShell.Run "\\server\deploy$\scripts\gepush.bat",0,True
Else
Wscript.Quit
End If
End If
End If
Set wshShell = Nothing
Set objWMIService = Nothing
Function RegKeyExists(strName)
Const NO_EXISTING_KEY = "HKEY_NO_EXISTING\Key\"
Dim objWsh
Dim strKeyPath
Dim strNoKeyError
Set objWsh = WScript.CreateObject("WScript.Shell")
strKeyPath = Trim(strName)
If Right(strKeyPath, 1) <> "\" Then strKeyPath = strKeyPath & "\"
On Error Resume Next
' Get the error description by trying to read a non-existent key
objWsh.RegRead NO_EXISTING_KEY
strNoKeyError = Err.Description
Err.Clear
objWsh.RegRead strKeyPath
' Compare the error description with the previous determined sample
If Replace(Err.Description, strKeyPath, _
NO_EXISTING_KEY) = strNoKeyError Then
RegKeyExists = False
Else
RegKeyExists = True
End If
Err.Clear
On Error Goto 0
Set objWsh = Nothing
End Function
I am wanting to have a VBscript that will check to see if an application is installed. If it is not installed then I want to install it. If it is installed then I want to check the version and see if it is the newest version and if it is not a certain version then lets send the upgrade file to be installed.
This is what I have so far below. It just basically checks to see if it is installed and if it isn't then it installs the 2 .msi files from a batch file. I would love to have them all install from a vbs file, but I have had a hard time getting that to do work since you cannot install 2 .msi files at the same time.
----
Set wshShell = WScript.CreateObject("WSCript.shell")
strOS = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName")
If strOS = "Microsoft Windows XP" or Left(strOS,9) = "Windows 7 Professional" Then
If strOS = "Microsoft Windows XP" Then
'Lets Check for GuardianEdge and see if it is installed. If not, lets install it.
If Not RegKeyExists("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{7EDD1CCA-F75D-4DB2-A958-B2E83C840EAF}") Then
wshShell.Run "\\server\deploy$\scripts\gepush.bat",0,True
Else
Wscript.Quit
End If
End If
End If
Set wshShell = Nothing
Set objWMIService = Nothing
Function RegKeyExists(strName)
Const NO_EXISTING_KEY = "HKEY_NO_EXISTING\Key\"
Dim objWsh
Dim strKeyPath
Dim strNoKeyError
Set objWsh = WScript.CreateObject("WScript.Shell")
strKeyPath = Trim(strName)
If Right(strKeyPath, 1) <> "\" Then strKeyPath = strKeyPath & "\"
On Error Resume Next
' Get the error description by trying to read a non-existent key
objWsh.RegRead NO_EXISTING_KEY
strNoKeyError = Err.Description
Err.Clear
objWsh.RegRead strKeyPath
' Compare the error description with the previous determined sample
If Replace(Err.Description, strKeyPath, _
NO_EXISTING_KEY) = strNoKeyError Then
RegKeyExists = False
Else
RegKeyExists = True
End If
Err.Clear
On Error Goto 0
Set objWsh = Nothing
End Function