Archive for the ‘Proses Batch’ Category

Subinstruksi SHIFT

Changes the position of replaceable parameters in a batch file.

SHIFT [/n]

If Command Extensions are enabled the SHIFT command supports the /n switch which tells the command to start shifting at the nth argument, where n may be between zero and eight. For example:


would shift %3 to %2, %4 to %3, etc. and leave %0 and %1 unaffected.

Categories: Proses Batch

Subinstruksi REM

Records comments (remarks) in a batch file or CONFIG.SYS.

REM [comment]

Categories: Proses Batch

Subinstruksi PAUSE

Suspends processing of a batch program and displays the message

Press any key to continue . . .

Categories: Proses Batch

Subinstruksi IF

Performs conditional processing in batch programs.

IF [NOT] ERRORLEVEL number command

IF [NOT] string1==string2 command

IF [NOT] EXIST filename command

  • NOT – Specifies that Windows XP should carry out the command only if the condition is false.
  • ERRORLEVEL – number Specifies a true condition if the last program run returned an exit code equal to or greater than the number specified.
  • string1==string2 – Specifies a true condition if the specified text strings match.
  • EXIST filename – Specifies a true condition if the specified filename exists.
  • command – Specifies the command to carry out if the condition is met. Command can be followed by ELSE command which will execute the command after the ELSE keyword if the specified condition is FALSE

The ELSE clause must occur on the same line as the command after the IF. For example:

IF EXIST filename. (
	del filename.
) ELSE (
	echo filename. missing.

Read more…

Categories: Proses Batch

Subinstruksi GOTO

Directs cmd.exe to a labeled line in a batch program.

GOTO label

  • label – Specifies a text string used in the batch program as a label.

You type a label on a line by itself, beginning with a colon.

If Command Extensions are enabled GOTO changes as follows:

GOTO command now accepts a target label of :EOF which transfers control to the end of the current batch script file. This is an easy way to exit a batch script file without defining a label. Type CALL /? for a description of extensions to the CALL command that make this feature useful.

Categories: Proses Batch

Subinstruksi FOR

Runs a specified command for each file in a set of files.

FOR %variable IN (set) DO command [command-parameters]

  • %variable – Specifies a single letter replaceable parameter.
  • (set) – Specifies a set of one or more files. Wildcards may be used.
  • command – Specifies the command to carry out for each file.
  • [command-parameters] – Specifies parameters or switches for the specified command.

To use the FOR command in a batch program, specify %%variable instead of %variable. Variable names are case sensitive, so %i is different from %I.

If Command Extensions are enabled, the following additional forms of the FOR command are supported:

FOR /D %variable IN (set) DO command [command-parameters]

  • If set contains wildcards, then specifies to match against directory names instead of file names.

FOR /R [[drive:]path] %variable IN (set) DO command [command-parameters]

  • Walks the directory tree rooted at [drive:]path, executing the FOR statement in each directory of the tree. If no directory specification is specified after /R then the current directory is assumed. If set is just a single period (.) character then it will just enumerate the directory tree.

Read more…

Categories: Proses Batch
%d bloggers like this: