Skip to content

Instantly share code, notes, and snippets.

@paveltimofeev
Last active June 2, 2016 08:39
Show Gist options
  • Save paveltimofeev/6fe2a741752baf55aef71fdb6a10216f to your computer and use it in GitHub Desktop.
Save paveltimofeev/6fe2a741752baf55aef71fdb6a10216f to your computer and use it in GitHub Desktop.
Batch (CMD) hints, tips & tricks

Batch (CMD) hints, tips & tricks

"try-catch" for bat-files

my-command with parameters && (
  
  echo - my-command completed successfuly

  (call)
) || (
  
  echo - my-command failed
)

echo - finally

Redirect stderr

REM suppress 'some.file not found' message
del %TEMP%\some.file /Q 2> nul

REM redirect 'some.file not found' message to errors.log
del %TEMP%\some.file /Q 2> errors.log

REM redirect all outputs to delete.log
del %TEMP%\some.file 1> delete.log 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment