WMIC command to read registry Uninstall keys ...

J

Joe

I'm trying to get a more accurate list from WMIC than from the "wmic
product list brief". I'd like to simply read all the registry keys
under
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",
but I can't figure out how to navigate to that key using "WMIC
REGISTRY"! Documentation on the internet is really scarce and the only
examples I can find list NO useful information for navigating the
registry using WMIC.

I'm new to both WMIC and WMI, so that may be why I'm hitting this wall.

By the way, I'm hoping for a fully WMIC command, not any vb script or
WMI commands (there are a lot of those on the internet already). It
should be possible with one line of code in WMIC to accomplish this.
Thanks!
 
G

Guest

Not totally what you are looking for, but here IS a vbscript that could do
what you are asking. The script deletes all keys below a specified root-key
(Software\Microsoft\SMS). You would need to modify it a little to only READ
each key and dump the values in a text-file.

God Bless You!!

::::::::::::::::::::::::
Start of VBscript
::::::::::::::::::::::::

'Const HKEY_CLASSES_ROOT = &H80000000
'Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
'Const HKEY_USERS = &H80000003
Const ForReading = 1, ForWriting = 2, ForAppending = 8 'Used for
opening/creating/modifying text-files

Set objArgs = WScript.Arguments 'Create object to capture command-line
arguments into an object,
'for later use as a variable.
strSecondarySiteServer = objArgs(0) 'Sets/Initialize variable to first
command-line parameter which is
'the server-list

' Object used to get StdRegProv Namespace
Set wmiLocator = CreateObject("WbemScripting.SWbemLocator")

' Registry Provider (StdRegProv) lives in root\deafult namespace.
Set wmiNameSpace = wmiLocator.ConnectServer (strSecondarySiteServer,
"root\default")
Set objRegistry = wmiNameSpace.Get ("StdRegProv")

' Example Deletion of Value
sPath1 = "SOFTWARE\MICROSOFT\NAL"

'lRC = DeleteRegEntry(HKEY_LOCAL_MACHINE, sPath)
lRC = DeleteRegEntry(HKEY_LOCAL_MACHINE, sPath1)


sPath2 = "SOFTWARE\MICROSOFT\SMS"

lRC = DeleteRegEntry(HKEY_LOCAL_MACHINE, sPath2)

'objOutputFile.Writeline vbCrlf

Function DeleteRegEntry(sHive, sEnumPath)

' Attempt to delete key. If it fails, start the subkey
' enumration process.

lRC = objRegistry.DeleteKey(sHive, sEnumPath)

Select Case lRC

Case 0
'Registry key successfully deleted
Case 2
'Registry key does not exist
Case Else
' Subkey Enumerator
On Error Resume Next
lRC = objRegistry.EnumKey(sHive, sEnumPath, sNames)

For Each sKeyName In sNames

If Err.Number <> 0 Then
Exit For
End If

lRC = DeleteRegEntry(sHive, sEnumPath & "\" & sKeyName)

Next

On Error Goto 0

' At this point we should have looped through all subkeys, trying
' to delete the registry key again.
lRC = objRegistry.DeleteKey(sHive, sEnumPath)

End Select

End Function


::::::::::::::::::::::::
End of VBscript
::::::::::::::::::::::::
 
Joined
Mar 2, 2007
Messages
1
Reaction score
0
Is it too late ?

Try this one :
*you can try to pipe the result to a text file or you can use batch script to capture the return value

To read registry value : HCU\Test\Data (REG_SZ type)
> /namespace://root/default
>class stdregprov call getstringvalue hDefKey=&H80000001 sSubKeyName='TEST' sValueName='DATA'

To write to registry use setstringvalue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top