Archive for the 'DOS Functions' Category

DOS/Batch Commands/Functions Descriptions

DEL and ERASE
In Windows NT, the DEL and ERASE commands are much more powerful than they are in other versions of MS-DOS and Windows. Although the basic syntax remains the same, Windows NT offers several switches that allow DEL to behave like the DELTREE command. Using the appropriate switches, it’s also possible to delete files [...]

Wait, Sleep, Hold - :sleep

The :sleep function puts the batch execution on hold for a certain amount of second.
:sleep -– waits some seconds before returning
::     — %~1 – in, number of seconds to wait
FOR /l %%a in (%~1,-1,1) do (ping -n 2 -w 1 127.0.0.1>NUL)
goto :eof

Get THIS computers IP address - :getIP

The getIP function filters the IP address from the ipconfig command output and returns it to the caller.
Code
:getIP — return THIS computers IP address
::     — %~1 - out, IP
SETLOCAL
set ip=
for /f “tokens=2,* delims=:. ” %%a in (’”ipconfig|find “IP Address””‘) do set ip=%%b
( ENDLOCAL & REM RETURN VALUES
IF “%~1″ NEQ “” (SET %~1=%ip%) ELSE (echo.%ip%)
)
goto :eof
Test [...]