Unable to delete a registry key


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

Answers (4)

Posted by: EdT 6 years ago
Red Belt
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.
Posted by: anonymous_9363 6 years ago
Red Belt
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.

  • 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. - Yellow74 6 years ago
Posted by: StockTrader 6 years ago
Red Belt

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

  • But the keys I want to delete I not under HKCU but under HKLM... I thought it would work with the local admin account... - Yellow74 6 years ago
    • 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,
      Marco - StockTrader 6 years ago
    • 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.
      Marco - StockTrader 6 years ago
Posted by: SMal.tmcc 6 years ago
Red Belt
try using HKLM64

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ