Can someone tell me what this VBScript does?

Status
Not open for further replies.
Associate
Joined
14 Jan 2004
Posts
841
Location
Reading, UK
Hi all,

Looking at a VBScript here - not mine - which purportedly checks if an application has been installed based on the presence of a reg key, but I can't get my head around how it works (if at all)?

On Error Resume Next
Set oShell = CreateObject("Wscript.Shell")

iRetVal = oShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\(35142) - G.H.O.S.T. Installer\DisplayName")

If iRetVal = "hibu (35142) - G.H.O.S.T. Installer (Run)" Then
oShell.Run "cscript ""C:\Program Files\Installers\G.H.O.S.T.\Install.vbs""", 0, True
Else
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\(35142) - G.H.O.S.T. Installer\",""
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\(35142) - G.H.O.S.T. Installer\DisplayName", "(35142) - G.H.O.S.T. Installer"
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\(35142) - G.H.O.S.T. Installer\DisplayVersion", "1.0"
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\(35142) - G.H.O.S.T. Installer\UninstallString", "(35142) - G.H.O.S.T. Installer"
End If

Any thoughts?
 

Pho

Pho

Soldato
Joined
18 Oct 2002
Posts
9,325
Location
Derbyshire
Here's a commented version:

PHP:
' If any error occurs during this script, continue with the next line rather than bail out
On Error Resume Next

' Create oShell as a variable which provides access to Wscript.Shell
' which lets this script run other executables
Set oShell = CreateObject("Wscript.Shell")

' Create varaible iRetVal which is the value of the reg key specified
iRetVal = oShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\(35142) - G.H.O.S.T. Installer\DisplayName")

' If the value of the reg key is "hibu (35142) - G.H.O.S.T. Installer (Run)" (e.g., it exists) then:
If iRetVal = "hibu (35142) - G.H.O.S.T. Installer (Run)" Then
' Execute the C:\Program Files\Installers\G.H.O.S.T.\Install.vbs script
oShell.Run "cscript ""C:\Program Files\Installers\G.H.O.S.T.\Install.vbs""", 0, True
' If the value of the reg key is NOT "hibu (35142) - G.H.O.S.T. Installer (Run)" then:
Else
' Create root reg key
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Un install\(35142) - G.H.O.S.T. Installer\",""
' Create reg key Displayname with value "(35142) - G.H.O.S.T. Installer"
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Un install\(35142) - G.H.O.S.T. Installer\DisplayName", "(35142) - G.H.O.S.T. Installer"
' Create reg key DisplayVersion with value "1.0"
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Un install\(35142) - G.H.O.S.T. Installer\DisplayVersion", "1.0"
' Create reg key UninstallString wuth value "(35142) - G.H.O.S.T. Installer"
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Un install\(35142) - G.H.O.S.T. Installer\UninstallString", "(35142) - G.H.O.S.T. Installer"
End If


So basically what it's doing is checking if a reg key exists. If it does, then it launches install.vbs. If it doesn't, then it creates the reg key for what looks like the game uninstaller and sets a few values.
 
Status
Not open for further replies.
Back
Top Bottom