Detailed Explanation of PECMD in WinPE—-PECMD.INI File Configuration ( 1 )
At present, most domestic WinPE systems are supported by a core software which is pecmd.exe (referred to a command line interpretive program), and there are more than 70 items in it.
1. Command category
1.1 Commonly used command line
1.2 Window controls, subroutine command
1.2.1 System variables
CurDir —- Current Directory
Desktop —- Desktop
Favorites —- Favorites
Personal —- My Documents
Programs —- Programs
Send To —- Sent To
Start —- Start Menu
Startup —- Automatic Operation
Quick Launch —- Quick Launch Bar
System Driver —- System Partition
System Root —- System Folder
1.2.2 Commonly used controls
ComboBox, Button, Picture, CheckBox, HotKey, PopupMenu, Progress, BarGroup, Static, Timer, Radio, CHEK, Menu, LABE, EDIT, GROU, IMAG, ITEM, MEMO, PBAR, TIME, RADI
1.3 Character string, character control
LPOS, LSTR, MSTR, RPOS, RSTR, STRL
1.4 Window, subroutine sign
1.5 Commonly used commands
BROW, CALC, CALL, DATE, DEVI, DISP, EJEC, ENVI, EXEC, EXIT, FBWF, FDIR, FDRV, FEXT, FILE, FIND, FONT, FORX, HELP, HKEY, HOTK, IFEX, INIT, KILL, LINK, LIST, LOAD, LOGO, LOGS, MAIN, MD5C, MENU, MESS, MOUN, NAME, NUMK, PAGE, PATH, RAMD, REGI, RUNS, SEND, SERV, SHEL, SHOW, SHUT, SITE, SUBJ, TEAM, TEMP, TEXT, TIPS, UPNP
Format: _SUB <sub-process name> or _SUB <window name>, <window shape>, [window title], [window event], [window icon], [window type]
Function: define a sub-process or define a window.
■ Sub-procedure name: character string
■ Window name: character string. Window name should be unique and can not be same as other control names or environment variable names.
■ Window title: text
■ Window shape: window position and size. The format is <LTWH>, in which L stands for Left, T for Top, W for Width, H for Hight. And all of them are numerical values. Besides, if the Left and Top are omitted, the window will be centered.
■ Window event: The command is executed when closing the window. And it must be a command supported by PECMD.EXE.
■ Window icon: icons in the window title bar and taskbar. Its format is < icon file name # ID>
■ Window type: [ – ] [ # ] [ value ]. ” – ” stands for no title bar, “# ” for the chromeless window, and value for transparency. Moreover, value higher than 99 is hidden window.
◆ _SUB DoLoop
◆_SUB Windows1, W360H440, PECMD function demonstration, EXEC $instructions, TXT,%IconFile%#19,20
※ The first character of sub-process name or window name can not be a “$”. And there must be a space between the command keyword _SUB and the sub-process name or window name.
※ If there are multiple _SUB commands, names used for defining the commands can not be repeated and approximated. These names can not be set as environment variables.
※ This command must come in pair with _END command. And both of them can not be used in the command line. For other information, please refer to the illustration of _END command and CALL command.
※ To set the window title, you can use the “ENVI @window name=window title”. Please make reference to the explanation of ENVI command.
Format : _END
Function: End sub procedure or window definition.
※ When defining sub-process’s _SUB command and _END command, they must be a separate line. In other words, the FIND, IFEX, TEAM commands can not defined sub-process within them. http://www.dabaicai.com/
※ The command between _SUB and _END ( i.e. sub-process ) can only be executed by the corresponding CALL command, while the main process will skip these commands.
※ _END command must match with _SUB command, and the sub-process can not define sub-process within it.
※ The sub-process placed at any position of the configuration file can be called by CALL command in the same configuration file. And it is suggested to put it at the beginning of the file.
※ This command and _SUB command can only be used in the configuration file, and can not be used in the command line.
Format : BROW <variable name>, [[* | &]initial path], [tip text], [extensions]
Function: Browse disk files and directory.
■ Variable Name: variable name used for saving the browse result
■ Initial Path: Default the selected files or directory for the browser window. When this parameter is omitted, it will locate to the system default path. Moreover, leading character “*” represents directory browse dialog, the leading character “& ” stands for save file dialog, and omitting the leading character means open file dialog.
■ Tip Text: It can be omitted. When it is omitted, the default text is the system default tip text.
■ Extension: Browse the specified file’s extension. If it is omitted, the file represents all files.
◆ BROW Boot_Ini, C: \ Windiws \ BOOT.INI, please select a file, INI
◆ BROW Tag, * C: \ Windiws, please select a directory
※ This command opens a file directory browsing dialog box, allowing users to browse the disk file directory. And the user can select certain file or directory.
※ Selection result will be saved in the specified process environment variable. Example 2 can be referenced through the environment variable %Tag%.
※ BROW command must be executed after the INIT command or on the desktop .
Format : CALC [#] <variable 0><=><variable 1><operator> <variable 2>
Function: Operate “variable 1” and “variable 2” as “operator “, and store the operation result in the “variable 0”.
■ Leading character “#” indicates that all variables are managed according to int data type. If the leading character is omitted, it indicates that all variables are managed according to double data type.
■ “Variable 1” and “variable 2″ can be specific values, or existing variables.
■ ” Operator” currently only supports four kinds of operations including “+ “, ” – “, “* “, “/ “.
◆ Add operation: CALC #Sum = 128 + 32 or CALC Sum =%Datum1% +%Datum2%
◆ Multiplication: CALC #Result = 128 * 64 or CALC Result =%Datum1% * %Datum2%
※ “Variable 1” or “variable 2” can be directly set by ENVI command (referred to assignment), or be the result of assignment operated by CALC command.
※ When “variable 1” or “variable 2” has no assignment, it can be processed as value “0”. To complete complex four arithmetic operation, you can use a series of CACL commands.
※ When CACL command uses double type variables to process data, up to four decimal places can be reserved. Moreover, to compare the numerical size, IFEX command can be used.
Format : CALL <$DLL name>, [function], [[#]parameter 1], [[#]parameter 2], [[#]parameter 3], [[#]parameter 4] or CALL <process> or CALL <@ window>
Function : Calling DLL function or subprocess.
■Leading character “$” indicates calling DLL functions, specifying DLL path, function name and parameters. If the function name is omitted, “DllRegisterServer” will be called, and parameters are defaulted as UNICODE string. If the leading character of parameters is “#”, it indicates integer. And up to four function parameters are supported.
■ Leading character “@” indicates calling a window defined by the _SUB command. Don’t execute CALL @another window in the window defined by the _SUB command.
■If the leading character “$” is omitted, it indicates calling sub-process, and the parameters are the names of subprocesses.
◆ Call DLL function: CALL $ SHELL32.DLL, DllInstall, # 1, U
◆ Call window procedure: CALL @ Window1
◆ Call subprocess: FIND MEM> 127, CALL EXPLORER_SHELL! CALL CMD_SHELL
※ Call DLL functions : Functions in DLL must be exported in the way of STDCALL. (If you do not understand what it means, you can take it as no problem.)
※ Call window procedure: When using CALL’s leading character “@ ” to call a window, the execution of the commands after CALL command will be suspended until the window is closed.
※Call subprocess: CALL command can only invoke sub-processes in the same configuration file, and its function of calling sub-process can not be used in the command line. As for other information, please refer to illustration of _SUB and _END commands.
Format : CHEK < check box name >, < check box shape >, [ check box title ], [ check box event ], [ check box state ]; Function: Establish a check box control in a window defined by _SUB.
■ Check box name: string. The check box name should be unique, and can not be same as other controls’ names or environment variables’ names.
■ Check box shape: check box’s location and size. Format : <LTWH>. L stands for Left, T for Top, W for Width, H for Hight. And all of them are numerical values.
■ Check box Title: It is the text on the check box, and the text is used to describe the check box’s function or description.
■ Check box event: When clicking the check box, the command executed must be a valid command supported by PECMD.
■ Check box state: numbers. 1 or -1 stands for checked state, 0, 2 or -2 for not checked state, and less than 0 for gray unavailable state.
◆ CHEK Check1, L180T336W100H20, writable mount , 1
※ CHEK command must locate between _SUB command and _END command. CHEK command located at other places is invalid. Please refer to the descriptions of _SUB and CALL commands.
※ Environment variables: %check box name% is the check box title. To set the title, you can use “ENVI @check box name=check box title” .
※ Use “ENVI @check box name. Check=numerical value” to set the check box checked state. If the value is 0, the check box state is not checked state. While non-zero value represents checked state.
※ Use “ENVI @check box name. Enable=numerical value” to set the check box’s available state. 0 stands for disabled state, while non-zero value represents available state.
Format : DATE [ variable name ]; Function: Return to the current date and time of system
■ Variable name: save the variable names of system’s current date and time
◆ DATE SysDate
※ The result is saved as ” Year – Month – Day | Week | Hour: Minute: Second” in the specified variable. To remove the ” date” or “time” , please use string processing commands of PECMD (LPOS, RPOS, LSTR, MSTR, RSTR) to deal with.
※ If the ” variable names ” is omitted, the result is stored in the environment variable %CurDate%. Then the example results may be “2008-8-8 | 5 | 20:8:8”.
Format : DEVI [$] <CAB path>
Function: Find (and install ) driver from a CAB file or the specified folder.
■Specified CAB file path. The leading character “$” means installing the driver after extracting driver file. Otherwise, do not install the driver.
◆ DEVI %SystemRoot% \ DRV.CAB
※ This command uses the custom driven search algorithm (rather than the system’s), which can quickly extract the drive programs that may be used. Therefore , a device can search for multiple drivers.
※ In the CAB , put each driver in a separate directory, and ensure that the INF file in CAB is always located at the beginning of the current directory. Meanwhile, the INF file in CAB must be processed. And it is recommended to use matching program XCAB to make.
※ INF files are extracted to the “%SystemRoot%\INF” directory, SYS files are extracted to %SystemRoot%\SYSTEM32\DRIVERS directory, and other files are extracted to %SystemRoot%\SYSTEM32 directory.
※ If other files need to be extracted to specified directories, you can use “#” in the file name to replace directory separators. For example, the file, “SYSTEM32#WBEM#MOF#XXX.MOF”, will be extracted to the directory of “% SystemRoot% \ SYSTEM32 \ WBEM \ MOF \ XXX.MOF”.
※Another function of the command: Search drivers in the local disks. e.g. “DEVI \ Windows, Display”. However, this command is not perfect, and it will prompt driver file dialog box. Therefore, this function temporarily provides no technical support.
Format : DISP [W horizontal resolution H vertical resolution] [B color depth ] [F refresh rate] [T wait(ms)]
Function : Set the display parameters.
■ Separately specify screen parameters. If omitted, use the original settings.
◆ DISP W1024 H768 B32 F70 T5000
※ The first three sets of parameters can be used alone. For example, to set the refresh rate as 75 , you can use DISP F75 .
Format : EDIT < edit box name >, < edit box shape >, [ edit box content ], [ edit box event ], [ edit box type ]
Function: Establish a single line text edit box in the window defined by _SUB command.
■ Edit box name: String. Edit box name should be unique, and can not be same as other controls’ names or environment variables’ names.
■ Edit box shape: edit box’s position and size. Format : <LTWH>. L stands for Left, T for Top, W for Width, H for Hight. And all of them are numerical values.
■ Edit box contents: string. The text filled when initializing the edit box.
■ Edit box events: The command which is executed by pressing the Enter key in the edit box. And it must be a valid command supported by PECMD.
■ Edit box type: number. The default value is 0, representing normal edit box; value greater than 0 indicates password input box; value less than 0 means gray disabled edit box.
◆ EDIT Edit1, L32T244W240H24, C: \ Windows, ENVI @ Label1 =% Edit1%
※ EDIT command must be located between _SUB command and _END command. EDIT command placed at other locations is invalid. Please refer to illustrations of _SUB and CALL commands.
※ To set the text in the edit box, you can use “ENVI @edit box name = text content”. Please make reference to explanation of ENVI command.
※ Use “ENVI @edit box name. Enable = numerical value” to set the edit box’s available state. 0 represents unavailable state and non-zero value stands for available state.
※ Use “ENVI @edit box name. ReadOnly =numerical value ” to set the edit box’s read-only status. 0 means non-read-only status, non-zero value is read-only state.
Format : EJEC [C-| U-| R:]
Function: Remove or eject the specified USB or CD ROM drive. The command’s function is not perfect. http://www.dabaicai.com/
■ Parameter “C-” will eject all possible CD-ROM discs; parameter “U-” will remove all possible USB disks.
■ Parameter “R:” will eject or remove the specified CD-ROM disks or USB devices. If it is omitted, all possible CD-ROM disks or USB devices.
◆ EJEC C-
◆ EJEC U-
◆ EJEC H:
※ This command is used in PE whose system tray has no U disk management icon. For PE whose system tray has U disk management icon, it is suggested to use system tray icon.
※ This command can not be used in the configuration file. The INIT command with “I” parameter will install the command’s function in the tray icon menu.
Format : ENVI [$ | @ | *] [ name ] [ [ = ] value ]
Function: Set or clear environment variables.
■ Specified the name and value of environment variable. If the leading character is omitted and a value is not specified, the environment variable is a variable whose specified name is deleted. .
■ Leading character ” $ ” means setting system-level environment variable. Without it, the command can only set the program’s internal used environment variable ( process level ).
■ Leading character ” @ ” indicates setting the name or title of window control.
■ Leading character ” * ” (omitting the name and value) represents writing CD-ROM drive letter as CDROM0, CDROM, CDROM1, CDROM2 in system environment variables.
◆ ENVI TEMP=%SystemDrive%\TEMP
※ If the program executed by “EXEC” is used, the program’s environment variables will be automatically inherited. In other words, if a “$ ” environment variable is set in the configuration file, it will be effective to the “EXEC” program behind.
※ Under the command prompt, you can use ENVI command without parameters to refresh environment variables.
※ When only parameter “$” exists, initialize the user folder. Under the command prompt, environment variables can also be refreshed.
Format : EXEC [=] [!] [@] [$] [&] <EXE path> [ parameters ]
Function: Execute EXE, BAT and CMD procedures.
■ Specified program path and parameters. Leading parameters are as follows: (They can be used simultaneously, regardless of the order.)
■ Leading character “=” means waiting for execution completion; the leading character ” ! ” means executing in hidden manner.
■ Leading character “@” means executing in the background Desktop (WinLogon). The execution is completely hidden and can not interact with the user, but it can be used for registration. e.g. “EXEC@PECMD.EXE CALL $ SHELL32.DLL, DllInstall, # 1, U”.
■Leading character “&” indicates modifying process shutdown code (articulating “ExitWindowsEx” function). It is advised to execute “EXEC & EXPLORER.EXE” to modify SHELL shutdown function. In this way, when executing “Start -> Shut down the system”, it will run “PECMD.EXE SHUT” command to shut down the computer.
■Leading character “$” denotes executing by ShellExecute function to open non-executable files such as TXT, BMP, etc.
◆ EXEC =! CMD.EXE /C “DEL /Q /F% TEMP%”
※ SHELL is also loaded through this command.
Format : EXIT
Function: Exit the current subprocess called by CALL command, or exit the configuration file process invoked by the LOAD command.
◆ IFEX $%Val%=10, EXIT! ENVI Val =
◆ FIND $%CancelIt% =YES, EXIT! ENVI CancelIt =
※ Example 1 indicates exiting the current process when the numerical value of the numerical variable Val is 10.
※ Example 2 indicates exiting the current process when CancelIt environment variable is YES.
Format : FBWF [P percentage of available memory] [L minimum value] [H maximum value]
Function : Set the FBWF cache
■ Maximum value and minimum value are MB.
◆ FBWF P20 L32 H64
※ Three parameters can be used alone. For example, FBWF L64 indicates mandatorily setting FBWF of 64M. Moreover, FBWF command must be used behind MOUN command.
Format : FDIR < variable name > <= > < file name >
Function: Return to the directory name (no ” \ ” at the last) where the specified “file name” is.
■ Variable name: variable name used to store directory name
■ File name: valid file name
◆ FDIR fPath = C: \ Windows \ System32 \ calc.exe
◆ FDIR aPath =% CurDir% \ Path1 \ Path2 \ FileName
※ When the file name is a relative path, the return value result is PECMD.EXE working directory or configuration file’s working directory.
※ The result of example 1 is “C: \ Windows \ System32”.
※ The result of example 2 is “% CurDir% \ Path1 \ Path2”.
Format : FDRV < variable name > <=> [ file directory name]
Function: Return to the partition letter (end with “:” and no ” \ ” at the last) where the specified ” file directory name” is or all system drive letters.
■ Variable name: variable name used for saving partition letter
■ File name: legitimate file directory name (It can be omitted. When omitted, it has other meaning. Please refer to the “Remarks” explanation.)
◆ FDRV fDrive=C: \ Windows \ System32 \ calc.exe
◆ FDRV AllDrive=
※ When the file name is a relative path, the return value result is the partition letter where the PECMD.EXE working directory or configuration file’s working directory is.
※ Return all system drive letter when omitting “file directory name”. The return value is in the form of C: | D: | E: | F: | …
※ The result of example 1 is “C:”, and the result of example is a list of all system drive letters. (Please note that this list is not fixed and will change at any time.)
Format : FEXT < variable name > <= > < file name >
Function: Return to the extension (without “.” ) of the specified file name.
■ Variable name: variable name used for saving the extension name
■ File name: valid file name
◆ FEXT fExt = C: \ Windows \ System32 \ calc.exe
◆ FEXT aExt = X: \ Path1 \ Path2 \ FileName
※ The result of example 1 is “exe”, while the result of example 2 is null value.
※ The return value of FDIR, FDRV, FEXT can be detected or compared by using FIND command.
Format : FILE < file path > [ operator ] [ target path ]
Function : Operate file or directory
■Specified the source file path and destination path, supporting wildcards. You can manipulate multiple files simultaneously with semicolons. Operator ” -> ” and “=> ” respectively correspond to move and copy, while no operators means deleting operation.
◆ FILE% SystemRoot% \ INF \ *. INF =>% TEMP%
※ If a RAMDISK is used to boot the system, you can delete useless file like a 2M NTOSKRNL.EXE after startup to increase writable space of the RAMDISK.
Format : FIND < condition > [ Command 1 ] [ ! Command 2 ]
Function : According to whether the conditional expression is established or not, execute command 1 if it is established; execute command 2 if it is not.
■ Condition: judgment for [ total memory ], [ total disk space ], [ key ], [ environment variables ] or [ memory process ]
■ Total memory: MEM < comparison operator > value
■ Total disk space: R: \ < comparison operator > value. “R:” represents the drive letter .
■ Keys: KEY < comparison operator > value
■ Memory process: memory process name
■ Environment variable: $%environment variable name% < comparison operator > environment variable value. The comparison of environment variables is not case-insensitive.
■ Comparison operator: Comparison operators include “<“, “>” and “=” which respectively indicates ” less than”, “greater than” and “equal”.
■ Numerical values: values used for comparison. The unit for disk and memory is MB, and the key value is the key code.
◆ FIND MEM <128, SHEL% SystemRoot% \ SYSTEM32 \ XPLORER2.EXE! SHELL% SystemRoot% \ EXPLORER.EXE
◆ FIND $% OUTSIDE% =, ENVI $ OUTSIDE =% CurDrv% \ external program
※ This command is very powerful and complex. It can be used by nesting FIND or IFEX to judge multiple conditions. The function of IFEX command is similar to this command’s.
※ The ” , ” after < conditional expression> can be replaced by ” * “.
※ When this command is nesting FIND or IFEX command, the nested command can not use the ” ! ” separator.
※ When the FIND command is used to detect keys, if user presses keys of ‘A’ ~ ‘Z’ or ‘0 ‘ to ‘9 ‘, the key result will be stored in the environment variable %PressKey%.
Format : FONT < font path >, [ initial partition ]
Function : Register font or external font.
■ font file path and the initial partition
◆ FONT% CurDrv% \ external program \ FONT
◆ FONT \ WINDOWS
◆ FONT \ WINDOWS, C:
※ When commanding the first character as ” \ “, this command will start from the specified initial partition to search all fonts under all partitions’ Windows \ Fonts directory, then install and register. Defining the initial partition can avoid searching existing floppy drives of the computer. If the initial partition is omitted, all partitions in the computer will be searched, including floppy disks.
Format : FORX [@] [[!] \] < File >, < variable > , [ value ] , < command > [ parameter, parameter … ] <% variable% > [ , parameter, parameter … ] [ , … ]
Function: matching file directory corresponding command operations, similar to the function of the command for command of CMD.EXE .
■ File : specified the file directory name which can be with wildcards character
■ Variable: specified variable name. It can not be the existed environment variable or window control name.
■ Value: It indicates executing command operation of corresponding number to the matching file directory. 0 or < 0 means executing command operation to all existing files.
■ Command : PECMD.EXE legitimate and valid command. The parameter format and number after the command are decided by it.
◆ FORX% CurDir% \ Path1 \ *. DLL, AnyDLL, 0, CALL% AnyDLL%
◆ FORX \ auto *. INF, AutoRunVirus, 0, FILE% AutoRunVirus%
◆ FORX! \ WinPE \ WinPE.INI, MyIni, 1, LOAD% MyIni%
※ This command can search for the file directory with attributes, such as the hidden attribute file directory.
※ Leading character ” \ ” means searching all partitions. ” ! ” indicates making reverse search for all partitions. In the two leading characters ” [ ! ] \ “, the ” ! ” can not exist alone.
※ Leading character ” @ ” indicates searching only the directory and making corresponding operation. If ” @ ” is omitted, it means searching only the files and operating accordingly.
※ Example 1 means registering all DLL in the directory of %CurDir% \ Path1 \.
※ Example 2 means deleting auto *. INF file in all partition root directories.
※ Example 3 means reversely searching for WinPE.INI in all partitions’ WinPE directories. Then use LOAD command to load the the first WinPE.INI.
Format : GROU < combination panel name >, < combination panel shape > , [ combination panel title ]
Function: Establish a combination panel in the window defined by _SUB command, for explaining the controls function and role in the combination panel.
■ Combination panel name: String. The combination panel name should be unique, and can not be same as other controls names or environment variables names.
■ Combination panel shape: combination panel location and size. Its format is<LTWH>, in which L stands for Left, T for Top, W for Width, H for Hight. And all of them are numerical values.
■ Combination panel title: string used to describe the role and function of the combination panel .
◆ GROU Group1, L8T4W336H400, register WimShExt.DLL
※ GROU command must locate between _SUB command _END command. GROU command placed at other locations is invalid. Please refer to illustrations of _SUB and CALL commands.
※ To set the combination panel title, you can use “ENVI @ combination panel name = combination panel title”. Pleas make reference to the description of ENVI commands. http://www.dabaicai.com/
Format : HELP [ text foreground color ] [ # text background color ]
Function: Display help information
■ Value ( supporting hexadecimal )
◆ HELP 0x00EEFF # 0xFF0000
※Directly executing the program without command line parameters will display help information as well.
Format : HKEY [ modifier keys + ] <# virtual key code > , <hotkey command >
Function : Set the system hotkey and assign the command executed by the hotkey.
■ Auxiliary keys: 4 modifier keys (Alt, Ctrl, Shift and Win) can be represented as string. Use modifier keys “+ ” to connect the modifier keys.
■ Key code: A key is represented by a virtual key code. Hexadecimal values is supported.
■ Hotkey command: It must be valid command supported by PECMD.
◆ HKEY # 255, SHUT R
◆ HKEY Ctrl + Alt + # 0x41, DISP W800H600B16F75
※ HKEY command must locate between _SUB command and _END command. HKEY command placed at other locations is invalid. Please refer to illustrations of _SUB and CALL commands.
※ The first example is calling SHUT command to restart when pressing the power button.
※ The set hotkey can not be conflict with hot keys of other programs .
Format : HOTK [ modifier keys + ] <# virtual key code >, < command >
Function : Set the system hotkey and assign the command executed by the hotkey. (. EXE or . CMD or . BAT)
■ 4 auxiliary keys can be represented by strings, and other keys by virtual key code. Hexadecimal values is supported.
◆ HOTK # 255, PECMD.EXE SHUT E
◆ HOTK Ctrl + Alt + # 36, PECMD.EXE
※ The first example is calling SHUT command of PECMD to shut down the computer when pressing the power button.
※ This command can not be used in the command line. It can only be used in the configuration file. PECMD can set up to 8 groups hot keys.
※ The register result of hot keys is in the registry’s “HKEY_LOCAL_MACHINE \ SOFTWARE \ PELOGON”.
※ SHEL command must be behind HOTK command.
※ Only by using SHEL command to load SHELL, can you register hot keys by use of HOTK command.