Batch-101 Flashcards
What are the types of Commands we have in Batch?
Internal : DIR, COPY, DEL
External: Format, Undelete, Backup
Which keyword to use for comment
REM
Which command to use forEcho
ECHO
How can we made the echo off
ECHO OFF
How can we prevent a particular command to still be shown but get executed
USe @ before the keyword
How can we pause for user reaction?
Do ECHO Warning: Statement PAUSE
What REM command does?
It will delete *.doc file in the folder
What does autoexec,bat does?
It gets executed every time the windows starts, it takes data from Path variable and run the commancd accordingly
How to capture the param from the command line?
Use %1, %2 and keep the counting with the no of params passed
Which command is used to comeout to windows back?
EXIT
So java, mongo and the like has batch utility to run and execute?
Exactly
What is the command for For Loop
FOR %%A in (items) DO …
Can we have %%[0-9] IN (items) DO…
NO only letters
What is the syntax for IF
IF [NOT] EXIST (ECHO…)
Can we Goto commancd
Yes, IF EXISTS C:/text.txt GOTO ME GOTO END
:ME ECHO ME End
Can we use IF back to back
Yes, IF EXIST C:/test.txt IF EXIST C:/ME.txt ECHO BOTH EXISTS
What is NULL device
Each directory ahs null exists , which is unreadeable
How can you check the existence of a folder?
IF EXIST c:/WINDOWS/nul ECHO Windows folder exists
How can we check if a drive is valid?
IF EXIST c:/io.sys
How can we compare the Strings?
IF [NOT] string1 == string2 Command
What is sysntax for CHOICE?
CHOICE[string][/C:keys][/S][/N][/T:key;secs]
String : That you want display as comment
kEys: The char choices to be given
/S is to make them case insenstive
/N is to show the possible keys in bracket
/T:key;secs: key the o choose by defaultafter the secs (seconds) went out
WHAT is CHOICE/C :AN12
The error level for A is 1 and for N it is 2, if 1 is pressed error level 3 and 2 is pressed error level is 4
Can we use Errorlevels ?
Yes if command coupled with ErrorLevelis kewl
IF ERRORLEVEL 1 ECHO ….(for all > = 1)
What is > &»_space; does ?
One is to write and other is to append
What is > NUL?
To suppress the message to nothing
What is MORE and TYPE?
Type will shopw all the contents of the file, More will show part by part
What is the pipe command?
To feed the output of one command to another
Do we have TIME command?
Yes TIME
How we can start the folder?
Path START .