Unable to delete a registry key on remote pc using WMI

G

Guest

Hi,

I have problem deleting a Registry Key using WMI. Here is the script:

Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
StrComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\ODBC\ODBC.INI"
strKeyPath1 = "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"

StrStringValueName = NameODBC

oReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath
oReg.DeleteValue HKEY_LOCAL_MACHINE, strKeyPath1, StrStringValueName

I try to delete strKeyPath but nothing happen. I succeed with deleting the
value.
I tried to use

strKeyPath = "SOFTWARE\ODBC\ODBC.INI\" &NameODBC but the result is same.

Please advice.
Thank you
 
D

Dave Patrick

Try asking them here. x-posted to: public.win32.programmer.wmi

http://www.microsoft.com/communitie...577-e09d-4532-b3ab-cc7cc38ebc4b&lang=en&cr=US

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| Hi,
|
| I have problem deleting a Registry Key using WMI. Here is the script:
|
| Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
| StrComputer & "\root\default:StdRegProv")
|
| strKeyPath = "SOFTWARE\ODBC\ODBC.INI"
| strKeyPath1 = "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"
|
| StrStringValueName = NameODBC
|
| oReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath
| oReg.DeleteValue HKEY_LOCAL_MACHINE, strKeyPath1, StrStringValueName
|
| I try to delete strKeyPath but nothing happen. I succeed with deleting the
| value.
| I tried to use
|
| strKeyPath = "SOFTWARE\ODBC\ODBC.INI\" &NameODBC but the result is same.
|
| Please advice.
| Thank you
|
 

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