Hi all. I'm very much a novice Vbscripter, so please be gentle. I have a script that I'm trying to have look for a value in the regitstry. If this value exists, I want it to write that same value to another key.
Here's the code I have so far. I have verified that the keys exist and that the value is correct, but the script keeps telling me that the product is not installed. I'd really appreciate any help. Don't have much hair as it is and I'm pulling that out! THANKS
Set WS = CreateObject("wscript.shell")
Set WshShell = Wscript.CreateObject("Wscript.Shell")
if RegistryValueExists("HKEY_CLASSES_ROOT\Installer\Products\E93843F1628446B41B3B245EEAD8CEA5\ProductName\ArcGIS Desktop 9.2 Concurrent") = false Then
MsgBox "Product Not installed"
Else
WS.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{E93843F1628446B41B3B245EEAD8CEA5}\DisplayName","ArcGIS Desktop 9.2 Concurrent"
end If
Function RegistryValueExists(RegistryValue)
'Ensure the last character is NOT a backslash (\) - if it is, we aren't looking for a value
If (Right(RegistryValue, 1) = "\") Then
'It's not a registry value we are looking for
RegistryValueExists = false
Else
'If there isnt the value when we read it, it will return an error, so we need to resume
On Error Resume Next
'Try reading the value
WshShell.RegRead RegistryValue
'Catch the error
Select Case Err
Case 0:
'Error Code 0 = 'success'
RegistryValueExists = True
Case Else
'Any other error code is a failure code
RegistryValueExists = False
End Select
'Turn error reporting back on
On Error Goto 0
End If
End Function
Here's the code I have so far. I have verified that the keys exist and that the value is correct, but the script keeps telling me that the product is not installed. I'd really appreciate any help. Don't have much hair as it is and I'm pulling that out! THANKS
Set WS = CreateObject("wscript.shell")
Set WshShell = Wscript.CreateObject("Wscript.Shell")
if RegistryValueExists("HKEY_CLASSES_ROOT\Installer\Products\E93843F1628446B41B3B245EEAD8CEA5\ProductName\ArcGIS Desktop 9.2 Concurrent") = false Then
MsgBox "Product Not installed"
Else
WS.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{E93843F1628446B41B3B245EEAD8CEA5}\DisplayName","ArcGIS Desktop 9.2 Concurrent"
end If
Function RegistryValueExists(RegistryValue)
'Ensure the last character is NOT a backslash (\) - if it is, we aren't looking for a value
If (Right(RegistryValue, 1) = "\") Then
'It's not a registry value we are looking for
RegistryValueExists = false
Else
'If there isnt the value when we read it, it will return an error, so we need to resume
On Error Resume Next
'Try reading the value
WshShell.RegRead RegistryValue
'Catch the error
Select Case Err
Case 0:
'Error Code 0 = 'success'
RegistryValueExists = True
Case Else
'Any other error code is a failure code
RegistryValueExists = False
End Select
'Turn error reporting back on
On Error Goto 0
End If
End Function