|
-
Jun 27th, 2010, 12:28 PM
#1
Thread Starter
New Member
wmi script in Visual Basic
hi,
The following code in the link
http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
works fine. I want to know how to include this wmi script inside a VB code ( I'm using Visual Studio -2008).
Code:
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Services"
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
WScript.Echo "Subkeys under " _
& "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services"
For Each subkey In arrSubKeys
WScript.Echo subkey
Next
-
Jun 27th, 2010, 02:24 PM
#2
Thread Starter
New Member
Re: wmi script in Visual Basic
Here is the code I had tried in Vb. The problem is, I can enumerate the folders inside the "SOFTWARE" key. When I open the registry editor, I can view "Product Installs" as a folder inside "SOFTWARE", but when I specify the strRootKey as "SOFTWARE" and list them, "Product Installs" is not being listed. Any help is highly appreciated!!
Code:
Dim refRegistry
Dim strRootKey
Dim subKey
Dim arrSubKeys
refRegistry = GetObject("winmgmts:root\default:StdREgProv")
Const HKEY_LOCAL_MACHINE = &H80000002
refRegistry = GetObject("winmgmts:root\default:StdRegProv")
strRootKey = "SOFTWARE\Product Installs"
If refRegistry.EnumKey(HKEY_LOCAL_MACHINE, strRootKey, arrSubKeys) = 0 Then
For Each subKey In arrSubKeys
ListBox1.Items.Add(subKey.ToString)
Next
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|