I am having a terrible time converting my VBScript to VB.
The VB program basically consists of an input box (for server Name) and listboxs and a module for registry functions. The VBScript (see below) connects to a remote server and enumerates a key and returns values for two subkeys. I can make a connect to a remote PC but am having trouble enumerating keys and returns values.
Any help would be greatly appreciated.
--- VBScript ---
'define symbolic constant for HKLM
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_MULTI_SZ = 7
On Error Resume Next
'retrieve StdRegProv class
strComputer = "BP1NAPSM001"
strSKPath = "SOFTWARE\Microsoft\SMS\Tracing"
Set WMIRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv"
If WMIRegistry.EnumKey(HKEY_LOCAL_MACHINE,strSKPath, arrKeys) = 0 Then
If Err <> 0 Then
wsh.echo "WMI Connection Error"
Else
For Each strKey In arrKeys
sResult = strKey
strPath = strSKPath & "\" & strkey
If WMIRegistry.GetStringValue(HKEY_LOCAL_MACHINE,strPath,"TraceFileName",sValue) = 0 Then
sResult= sResult & vbTab & sValue
If WMIRegistry.GetDWORDValue(HKEY_LOCAL_MACHINE,strPath,"Enabled",sValue) = 0 Then
sResult = sResult & vbTab & sValue
End If
Else
'call to GetStringValue() failed
wsh.echo " Unable to find the appropriate value"
End If
wsh.echo sResult
Next
End If
Else
wsh.echo "WMI Connection Error"
End If
Set WMIRegistry = Nothing
The VB program basically consists of an input box (for server Name) and listboxs and a module for registry functions. The VBScript (see below) connects to a remote server and enumerates a key and returns values for two subkeys. I can make a connect to a remote PC but am having trouble enumerating keys and returns values.
Any help would be greatly appreciated.
--- VBScript ---
'define symbolic constant for HKLM
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_MULTI_SZ = 7
On Error Resume Next
'retrieve StdRegProv class
strComputer = "BP1NAPSM001"
strSKPath = "SOFTWARE\Microsoft\SMS\Tracing"
Set WMIRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv"
If WMIRegistry.EnumKey(HKEY_LOCAL_MACHINE,strSKPath, arrKeys) = 0 Then
If Err <> 0 Then
wsh.echo "WMI Connection Error"
Else
For Each strKey In arrKeys
sResult = strKey
strPath = strSKPath & "\" & strkey
If WMIRegistry.GetStringValue(HKEY_LOCAL_MACHINE,strPath,"TraceFileName",sValue) = 0 Then
sResult= sResult & vbTab & sValue
If WMIRegistry.GetDWORDValue(HKEY_LOCAL_MACHINE,strPath,"Enabled",sValue) = 0 Then
sResult = sResult & vbTab & sValue
End If
Else
'call to GetStringValue() failed
wsh.echo " Unable to find the appropriate value"
End If
wsh.echo sResult
Next
End If
Else
wsh.echo "WMI Connection Error"
End If
Set WMIRegistry = Nothing