Jump to content

Recommended Posts

Posted

Hey all, I don't know if I'm missing something but I try to run a command to delete a registry entry, however, when it doesn't find the key, it throws an error on the screen instead of suppressing it.

Here is my code:

"REG DELETE HKLM\Software /f /v KeyToDelete >NUL"

If the entrie exists, it works properly, however, I get an error "Error: The system was unable to find the specified registry key or value"

Any ideas?


Posted

Well obviously if you try to get rid of something which doesn't exist you'd expect to see an error flagged.

There are two ways to prevent this behaviour:

  1. Only delete something if it exists. (proper method)
  2. Hide the error message. (lazy method - the one you want)

    either


    Reg delete "HK…" /v KeyToDelete /f >Nul 2>Nul


    or


    Reg delete "HK…" /v KeyToDelete /f >Nul 2>&1


Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...