User Tools

Site Tools


batchfiles

For full and parts of batchfiles.

Misc sources:
Commands index
Batch File Commands
Batfiles: The DOS batch file programming handbook & tutorial
Batch File Help
Batch file
Batch Guide by Terry Newton
Batch files for DOS, OS/2, Windows 95/98, NT 4, 2000 and XP

Checking for the existence of a specific registry key

rem ### Check for the presence of an ADI SoundMAX HD Audio chip, if detected install the HighDef audio update. ###
reg query "HKLM\SYSTEM\CurrentControlSet\Enum\PCI\VEN_8086&DEV_284B&SUBSYS_100C17AA&REV_02" > nul
IF ERRORLEVEL=1 goto theend
IF NOT ERRORLEVEL=1 goto patch

:theend
exit

:patch
c:\Resource\kb888111xp2en\update\update.exe /passive

REG.EXE

Check for the existence of 2 parameters necessary to run a command in batchfile

@echo off
REM If the first value is empty, goto forgot 1.
IF %1.==. goto forgot 1
REM If the fist value is NOT empty, goto next.
IF not %1.==. goto next

:command
REM The actual command to execute that requires 2 parameters.
@echo on
echo Hello %1 %2
@echo off
goto end

:next
REM If the second value is NOT empty goto command.
IF not %2.==. goto command
REM if the second value is empty echo a line and goto end.
IF %2.==. echo You forgot 2
goto end

:forgot 1
echo You forgot 1
goto end

:end
REM The script ends here.

Downloading a jpg image from a TCP/IP-camera

:begin
wget --http-user=username --http-passwd=pwd http://10.0.0.1/Jpeg/CamImg.jpg 
sleep 5
goto begin

Errorlevels of XCOPY

Errorlevel Betekenis
0 Files were copied without error
1 No files were found to copy
2 The user pressed CTRL+C to terminate XCOPY
4 Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command-line
5 Disk write error occurred

Source:XCOPY

Spawning a program from a batchfile while the batchfile continues

start cmd /c commando

One batchfile for x86 and x64 systems

IF %PROCESSOR_ARCHITECTURE% EQU x86 GOTO X86
IF %PROCESSOR_ARCHITECTURE% EQU AMD64 GOTO X64
GOTO END
batchfiles.txt · Last modified: 2012/01/31 11:20 by bas