Batch Files – Error Handling

I generally find the conditional command concatenation operators much more convenient than ERRORLEVEL. yourCommand && ( echo yourCommand was successful ) || ( echo yourCommand failed ) There is one complication you should be aware of. The error branch will fire if the last command in the success branch raises an error. yourCommand && ( … Read more

Random generator in the batch

MC ND is 100% correct on all counts within his answer, and also his follow-on comment. Each instance of CMD.EXE initializes the random number generator upon startup using a seed that is derived from the current time with 1 second resolution. All CMD.EXE processes that launch within the same second will get identical random number … Read more

Open a URL without using a browser from a batch file

If all you want is to request the URL and if it needs to be done from batch file, without anything outside of the OS, this can help you: @if (@[email protected]) @then @echo off rem **** batch zone ********************************************************* setlocal enableextensions disabledelayedexpansion rem The batch file will delegate all the work to the script engine … Read more