I've tried several things before coming here to ask this apparently simple question: how do I delete a registry (if it exists) using a script ?

The log always show me the following result:

Running as: admin
Checking if registry 'HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI\' value 'test' does exist did not succeed: (2)
You can see that the key I want to delete is seen, but I can't delete it.

This Windows 7 Professionnal 64 bits edition

Here is a screenshot from Kace:

Many thanks in advance for your help
0 Comments   [ + ] Show Comments


Please log in to comment

Community Chosen Answer

Since you are working on a 64 bit operating system, are you using the correct registry path?
This registry path is more likely to exist in the 32 bit area of the registry, ie:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC   since the odbc.ini entry is a left over from the 16 bit days.
Answered 12/16/2014 by: EdT
Red Belt

Please log in to comment


We have to assume you're talking about KBox scripting?

You're running 'As admin' which means that the script is going to run as the admin user or, more likely, as the local System account. If you need to test the profile for the logged-in user, you'll need to change the context in which the script runs. I can't tell you  how to do that, as I know nothing about KBox scripting but I would imagine that the Help file would have that information.
Answered 12/16/2014 by: VBScab
Red Belt

  • Thanks for your response.
    That's my only guess to do it, as we haven't received any sort of training... but if you have another suggestion to delete the keys I want to delete, do not hesitate to tell me how.
  • This content is currently hidden from public view.
    Reason: Member has been banned from the site
    For more information, visit our FAQ's.
Please log in to comment

you need to create an Online Kscript and then select one of these option to impersonate a particular user because HKCU exists in the user context only.
If you run as LocalSystem the HKCU is different from the user HCKU.
Every logged on user has his own HKCU.

 Stocktrader = Marco

Answered 12/16/2014 by: StockTrader
Red Belt

  • But the keys I want to delete I not under HKCU but under HKLM... I thought it would work with the local admin account...
    • So you make a check on the HKCU and a delete for a HKLM key?
      May you edit your question adding some screenshots of the script's steps or posting the XML of the Script?
      Kind regards,
    • So from the screenshot it seems that in the verify you are looking for a registry value but in the delete you want to delete a registry key...this may be the issue.
Please log in to comment
try using HKLM64
Answered 12/16/2014 by: SMal.tmcc
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja