twig123 Posted July 3, 2008 Posted July 3, 2008 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?
Yzöwl Posted July 3, 2008 Posted July 3, 2008 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:Only delete something if it exists. (proper method)Hide the error message. (lazy method - the one you want)eitherReg delete "HK…" /v KeyToDelete /f >Nul 2>NulorReg delete "HK…" /v KeyToDelete /f >Nul 2>&1
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now