Help - Search - Members - Calendar
Full Version: Batch >NUL code
MSFN Forums > Coding, Scripting and Servers > Programming (C++, Delphi, VB, etc.)

   
Google Internet Forums Unattended CD/DVD Guide
twig123
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
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

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

    or

    CODE
    Reg delete "HK…" /v KeyToDelete /f >Nul 2>&1
Google Internet Forums Unattended CD/DVD Guide
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.