セクシーコマンドープロンプト(違)

W-ZERO3[es]のWindowsMobile5環境でも、それなりにマクロが作れる環境が整ってきましたが、それでもバッチファイルで一気にドバーッとできればもっと楽なのに!とか思うわけですよ。
ということで、CE用のコマンドプロンプトここそこあそこを参考にインストールしてみました。スクロールバー周りの表示が若干怪しい気がしますが、それなりに使えそうな印象です。備忘録としてHELP内容を貼っておきます。著作権とか大丈夫かなぁ・・・文句言われたら消そう、そうしよう(自己正当化)

HELP(コマンド一覧)

The following commands are available:
 ATTRIB Set/display file attributes.
 CALL Call batch script.
 CD Change directory.
 CHDIR Same as CD.
 CLS Clear the screen.
 COPY Copy files.
 DATE Display/set system date.
 DEL Delete a file.
 DIR Print contents of a directory.
 ECHO Echo output on the screen or change echoing parameters.
 ERASE Same as DEL.
 EXIT Exit command interpreter.
 HELP Print help for command interpreter or individual commands.
 GOTO Transfer control to a label in batch processing.
 IF Conditionally execute a command.
 MD Create a directory.
 MKDIR Same as MD.
 MOVE Move/rename files.
 PATH Alias for SET PATH.
 PAUSE Suspend execution of a batch file.
 PROMPT Reconfigure system prompt.
 PWD Print current working directory.
 RD Remove directory.
 REM Record comments in batch file.
 REN Change file name.
 RENAME Same as REN.
 RMDIR Same as RD.
 SET Set or list environment variables.
 SHIFT Shift arguments of a batch file.
 START Start detached process.
 TIME Display/change system time.
 TITLE Set the window title for a CMD.EXE session.
 TYPE Output contents of a file or files to the screen.
Use HELP [command name] to display extended help for given command, or
HELP CMD to display help on general topics such as

IF、GOTO、SETあたりがバッチ作るのに役立ちそう。

IF

command input options, I/O redirection or CMD parameters.

Performs conditional processing in batch programs.

IF [NOT] ERRORLEVEL number command
IF [NOT] string1==string2 command
IF [NOT] EXIST filename command
IF [NOT] DEFINED variable command

NOT    Specifies that Windows CE 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.
command   Specifies the command to carry out if the condition is met.
string1==string2 Specifies a true condition if the specified text
     strings match.
EXIST filename Specifies a true condition if the specified filename exists.

The DEFINED conditional works just like EXISTS except it takes
an environment variable name and returns true if the environment
variable is defined.

最低限は使える感じですが、いくつか要検証ですね。

  • ERRORLEVELはまともに使えるのか?
  • ELSEは使えない?

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.

GOTO command 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.

ラベルに飛ばす以外、ファイル最後(:EOF)も使えるっぽいです。

SET

Displays, sets, or removes cmd.exe environment variables.

SET [variable=[string]]

variable Specifies the environment-variable name.
string Specifies a series of characters to assign to the variable.

Type SET without parameters to display the current environment variables.

SET command invoked with just a variable name, no equal sign or value
will display the value of all variables whose prefix matches the name
given to the SET command. For example:

 SET P

would display all variables that begin with the letter 'P'

SET command will set the ERRORLEVEL to 1 if the variable name is not
found in the current environment.

SET command will allow an equal sign (=) in the value of an environment
variable in any position other than the first character.

Windowsと違って初期値は何も設定されていませんでした。
ERRORLEVELを返せるのでSETをフラグっぽく使うこともできそうです。




いろいろ試すのに時間掛かりそうなんで、これ使ったバッチはしばらく作らないことにしよう、そうしよう(逃げ腰)