Hi,
My script does the below;
-takes a registry key input as a parameter from user with option k
-checks if the registry entered exists than exports that into a text file.
-if registry key doesn't exist than says: unable to open reg.......
The script below works fine in almost all operating systems except in Windows 2003.
The KeyExists function always returns a false result even though the entered key is correct and only in Win 2003 OS.
Set colNamedArguments = WScript.Arguments.Named
Set winsh = CreateObject("WScript.Shell")
StrFileName = "C:\reg.log"
If colNamedArguments.Exists("k") Then
StrKey = colNamedArguments.Item("k")
If KeyExists(StrKey) = True Then
Wscript.echo "Scanning entered registry: " & StrKey & "..."
StrKey = trim(StrKey)
winsh.run "regedit /e " & chr(34) & StrFileName & chr(34) & " """& StrKey &"""",0,True
Else
Wscript.echo "Unable to open reg entered: " & StrKey
End If
End If
Function KeyExists(ByVal key)
If right(key, 1) <> "\" Then key = key & "\"
On Error Resume Next
winsh.RegRead trim(key)
If Err.Number <> 0 Then
keyExists = False
Else
keyExists = True
End If
End FunctionAny help please ?
Thanks!