Jump to content

Batch >NUL code


Recommended Posts

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?

Link to comment
Share on other sites


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


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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