User Tools

Site Tools


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 "WINDOWNAME" /B "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.

/B flag makes windows not creating a new window.

Documentation start command: http://ss64.com/nt/start.html

Start cm with a command works like this. Use /k to start cmd with a commad.

start cmd /k "robocopy c:/path/to/dir c:/path/to/backup /E"

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!
)

Commands

SUBST

Create a virtual disk from a LOCAL folder

subst z: b:\user\betty\forms

# delete
subst z: b:\user\betty\forms \D
batch.1467181133.txt.gz · Last modified: (external edit)