Skip to content

Instantly share code, notes, and snippets.

@kodybrown
kodybrown / launch.bat
Created Oct 9, 2019
Launch random .URL file
View launch.bat
@setlocal EnableDelayedExpansion
@echo off
set "SourceDir=."
REM count the number of files
pushd "!SourceDir!"
set /a FileCount=0
for /f "usebackq delims=|" %%I in (`dir /a-d-s-h /b *.url`) do set /a FileCount+=1
popd
@kodybrown
kodybrown / example_usage.txt
Created Jul 31, 2019
batch file boilerplate template
View example_usage.txt
>template.bat /?
test v1.23
This is a sample batch file template,
providing command-line arguments and flags.
USAGE:
test.bat [flags] "required argument" "optional argument"
/?, --help shows this help
/v, --version shows the version
@kodybrown
kodybrown / launch.bat
Created Jul 31, 2019
launch random .url file
View launch.bat
@setlocal EnableDelayedExpansion
@echo off
set "SourceDir=."
REM count the number of files
pushd "!SourceDir!"
set /a FileCount=0
for /f "usebackq delims=|" %%I in (`dir /a-d-s-h /b *.url`) do set /a FileCount+=1
popd
@kodybrown
kodybrown / err.bat
Last active Jul 15, 2016
Batch file that tests setting a non-zero (error) and a 0 (success) errorlevel
View err.bat
@echo off
dir "%temp%" >NUL
echo err %errorlevel%
dir "c:\doesnotexist" >NUL 2>&1
echo err %errorlevel%
dir "%temp%" >NUL
echo err %errorlevel%