Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert VBScript to VB

Status
Not open for further replies.

mharcourt

Programmer
Apr 9, 2003
49
US
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 &quot;WMI Connection Error&quot;
Else
For Each strKey In arrKeys
sResult = strKey
strPath = strSKPath & &quot;\&quot; & strkey
If WMIRegistry.GetStringValue(HKEY_LOCAL_MACHINE,strPath,&quot;TraceFileName&quot;,sValue) = 0 Then
sResult= sResult & vbTab & sValue
If WMIRegistry.GetDWORDValue(HKEY_LOCAL_MACHINE,strPath,&quot;Enabled&quot;,sValue) = 0 Then
sResult = sResult & vbTab & sValue
End If
Else
'call to GetStringValue() failed
wsh.echo &quot; Unable to find the appropriate value&quot;
End If
wsh.echo sResult
Next
End If
Else
wsh.echo &quot;WMI Connection Error&quot;
End If

Set WMIRegistry = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top