batch
This is an old revision of the document!
Fallpits
#when using variables no empty spaces after equal VAR TEST1="WILL WORK" VAR TEST2 ="VAR WILL BE EMPTY"
call
To call another *.bat use
call "D:\...\compile.cmd"
start
To start a programm in the console, and pass it some parameters with empty spaces use the following syntax:
start "" "D:\Programme Portable\Putty\putty.exe" -ssh ubuntu@ec2-1-22-33-44.eu-east-3.compute.amazonaws.com:22 -l ubuntu -i "D:/Path to Key/ssh-putty-ubuntukey-private.ppk"
The first argument of “start” - is the window title. Pass an empty one, for the next command to be recognized as the path to the programm.
Printers
Put the following into the “run” field to see all possible commands.
rundll32 printui.dll,PrintUIEntry /?
:: delete network printer per batch rundll32 printui.dll,PrintUIEntry /dn /n "\\brian\OKI C5100 (v2)"
:: install a network printer per batch rundll32 printui.dll,PrintUIEntry /q /in /n "\\brian\HPColorSekri"
Counter
To use Counters - deplayed expanation must be used in batch. The Variables are then translated to numers eveny loop.
- It must be enabled by setlocal ENABLEDELAYEDEXPANSION
- variables are loaded by !var! von %var%
setlocal ENABLEDELAYEDEXPANSION set /A cnt=1 for %%f in (*.cer) do ( echo %%~nf set /A cnt=cnt+1 echo !cnt! )
batch.1457807067.txt.gz · Last modified: (external edit)