Internal functions of VistaPE
Contents
- General information
- Examples of typical scripts
- Description of commands and options
- Global variables
- Description of vistape.cfg format
- Recommendations for creating scripts
General information
Since the release of 9 engine VistaPE made an enormous amount of change, many function is now work automatically and added a new API scripts programs. With each new version of VistaPE, API becomes more adaptable and powerfull, sometimes changing internal mechanisms work, but always maintain scripts written earlier. Application API ensures portability and operability your scripts in all versions VistaPE. Information in this section is relevant VistaPE v12 beta 2 and newer versions.
VistaPE API is a powerful, advanced and comprehensive tool to facilitate the creation of typical script. In some cases, you may need to use standard commands WinBuilder documentation which can be found here. VistaPE supports placing files with programs in memory (boot.wim), and directly to the media, API supports all features and allows individually selected for each program. There is the possibility of including files directly to the program scripts, and is able to update the program without direct editing scripts, there is also an opportunity to copy already established in the program without special integration scripts, gathering information on the settings directly from the registry system and the large number of other possible opportunities facilitate the establishment of their own scripts and system optimization for specific tasks VistaPE one of the most simple and flexible tool in this regard.
The examples of typical scripts
As mentioned earlier, scripts can contain embedded programs, copy files from your directory or download programs directly from the Internet, are small examples of such scripts.
This script contains an embedded program, can build up in the shell list, creates labels on the desktop and Start menu and always gets out of memory (using vistape.wim):
Title=A43 File Management
Author=NightMan
Level=5
Version=011
Description=
Locked=false
Contact=vistape@vistape.net
Date=02.12.2007
Selected=True
Download_Level=1
[Variables]
%ProgramFolder%=A43
%ProgramEXE%=a43.exe
%ProgramTitle%=A43 File Management
[Process]
Echo,Processing %ProgramTitle%...
RunFromRam,True
Unpack,Files,A43.7z,True
Add_Shortcut,StartMenu
Add_Shortcut,Desktop
#
If,%pCheckBox3%,Equal,True,If,%pCheckBox4%,Equal,True,AddToPEShell,%ProgramTitle%,,True
If,%pCheckBox3%,Equal,True,If,%pCheckBox4%,Equal,False,AddToPEShell,%ProgramTitle%
#
[Interface]
pCheckBox3="Add to PE Shell",1,3,10,60,200,18,True
pCheckBox4="Set as default shell in PE Shell",1,3,10,80,200,18,False
[EncodedFolders]
Files
[EncodedFile-Files-a43.7z]
lines=276
The next script check the program's executable and can download it, if necessary:
Title=TotalCommander 7.03
Author=NightMan
Level=3
Version=12
Description=
Locked=false
Contact=vistape@vistape.net
Date=14.05.2008
Selected=True
Download_Level=1
[Variables]
%ProgramFolder%=totalcmd
%ProgramEXE%=totalcmd.exe
%ProgramTitle%=Total Commander
[Process]
If,NotExistFile,"%pFileBox1%\%ProgramEXE%",run,%ScriptFile%,Download
Echo,Processing %ProgramTitle%...
RunFromRam,True
CopyProgram,%pFileBox1%
Add_Shortcut,StartMenu
Add_Shortcut,Desktop
#
If,%pCheckBox3%,Equal,True,If,%pCheckBox4%,Equal,True,AddToPEShell,%ProgramTitle%,,True
If,%pCheckBox3%,Equal,True,If,%pCheckBox4%,Equal,False,AddToPEShell,%ProgramTitle%
If,%pCheckBox5%,Equal,True,Add_Shortcut,StartMenu,QuickLaunch
#
[Download]
Echo,"Downloading TotalCommander"
If,NotExistDir,%pFileBox1%,DirMake,%pFileBox1%
WebGet,"http://fileforum.betanews.com/sendfile/945901171/1/tcmdr703.exe","%pFileBox1%\tcmdr703.exe"
ShellExecute,Hide,#$q%Tools%\7z.exe#$q,"x -y #$q%pFileBox1%\tcmdr703.exe#$q -o#$q%pFileBox1%#$q"
FileDelete,"%pFileBox1%\FILE_ID.DIZ"
FileDelete,"%pFileBox1%\INSTALL.EXE"
FileDelete,"%pFileBox1%\LIESMICH.TXT"
FileDelete,"%pFileBox1%\README.TXT"
FileDelete,"%pFileBox1%\tcmdr703.exe"
ShellExecute,Hide,#$q%Tools%\7z.exe#$q,"x -y #$q%pFileBox1%\INSTALL.CAB#$q -o#$q%pFileBox1%#$q"
FileDelete,"%pFileBox1%\INSTALL.CAB"
DirDelete,"%pFileBox1%\d"
DirDelete,"%pFileBox1%\e"
[Interface]
pCheckBox3="Add to shell list",1,3,10,60,200,18,True
pCheckBox4="Set as default shell",1,3,10,80,200,18,False
pFileBox1=%ScriptDir%\TC,1,13,79,125,207,28,dir
pTextLabel1="Source folder",1,1,10,129,72,18,8,Normal
pTextLabel2="Total Commenter will be downloaded and installed automatically, if executable will not be found in source path.",1,1,10,172,436,40,8,Normal
pCheckBox5="Add QuickLaunch icon",1,3,10,101,200,18,True
The examples of API functions can be found in each standard script.
Description of commands and options
Most of scripts contain several sections:
- [Main] - script description, version, author, creation date ...
- [Variables] - script variable settings
- [Process] - this section is in the processing script constructor and contains commands to all necessary action
- [Interface] - the appearance of the script
- [EncodedFolders] - contains a built-in script program in a special encoding
- Title - program name
- Author - program author
- Level - running level - affects the order of scripts, for the program are always advised to use only 5 level
- Version - version of the script
- Description - Description of program / script
- Locked - off accidentally change the interface script
- Contact - way communication with the author of the script
- Date - date when create current version of a script
- Selected - choice script for processing during project compilation
- Download_Level - priority for script downloading
- 0 - Minimum
- 1 - Recommended
- 2 - Complete
- 3 - Beta
- %ProgramTitle% - program name
- %ProgramEXE% - main executable file may contain the path to the directory with the program
- %ProgramFolder% - name for target folder with program
- ReadENV - read VistaPE and source configuration from file %VistaInfo%, after this we have several variables:
- %DistLang% - language of source
- %SDIR% - source folder
- %SourceType% - source type (Windows Vista DVD or WAIK)
- %WimTools% - WIM tool (imagex or winutil)
- %SystemFiles% - folder with mounted system files, depended from source type
- %IMAGEX% - path to imagex.exe
- %BuildModel% - build model (normal or vistape.wim)
- %Shell% - default shell
- %ScreenResolution% - screen resolution
- %Locale% - locale setting for VistaPE
- %SysType% - type of host OS (x86 or x64)
- %GrubSkin% - skin for Grub4Dos
- %ForceAllToRam% - forcibly copy all program memory (vistape.wim)
- %WAIKDir% - folder with installed WAIK (if exist)
- Not_Compatible - ensures compatibility between different projects WinBuilder, example: "Not_Compatible, LiveXP or Not_Compatible, VistaPE"
- RunFromRam - start this program from memory (vistape.wim), the example: "RunFromRam True" or "RunFromRam, %pCheckBox1%"
- Unpack - extract program files from script, example:
"Unpack,Folder,AngelWriter.7z,True" - first option (Folder) - directory in script with archives;
second parameter (AngelWriter.7z) - archive name; third option (in this case " True ") is
used only in self extracting archives (files with exe extension), and used as a parameter
start, otherwise ignored.
If a directory with the script contain folder with the same name as the output folder (%ProgramFolder%), and it is a file named Programme (% ProgramEXE%),
is not extracting archive of the script, and copying files from this folder,
it is done for facilitate configuration and maintenance program without making immediate
changes in the script.
Also possible advanced usage of this function with directive to target folder and program executable (need for check extracting process), example:
"unpack,Files,%ProgramArchive%,,%target_win%,System32".
Brief description of the parameters:
"Unpack,[Folder],[Archive zip rar 7z and some exe],[True],[%Target_Prog%],[%ProgramFolder%],[%programExe%]"
For extracting archive we use "7z.exe", latest version support 7z, zip, rar and other archive formats. - CopyProgram - copy all files from source folder to target, example: "CopyProgram,c:\test" or "CopyProgram,%pFileBox1%". Also you can set target folder and executable file for check result, example: "CopyProgram,c:\test,%TargetDir%\Test,test.exe".
- Require_File - copy files from "windows\system32" folder, example: "Require_File,test.dll", file will be placed in "%TargetDir%\windows\system32\" folder
- RequireSysFile - copy files from source disk, example: "RequireSysFile,windows\system32\drivers\driver.sys", file will be placed to folder similar source folder, for example "%TargetDir%\windows\system32\drivers\"
- Add_Shortcut - add shortcut to program, example:
"Add_Shortcut,StartMenu,Office", first option - type of shortcut destination (StartMenu,
Desktop or AutoStart; QuickLaunch and SendTo is NOT supported), second option - program category, it will be ignored if you try place shortcut to Desktop.
It is possible to use advanced commands for creating a shortcut to any programs, for example: Add_Shortcut,StartMenu,,#$pSystemRoot#$p\System32\%ProgramEXE%,%ProgramTitle%,#$pSystemRoot#$p\System32\AbiWord.
Brief description of the parameters:
Add_Shortcut,[Type],[Folder],[FullFileName],[Title],[Work Folder],[Parameters],[IconFile( .ico .exe)],[StartMode(1, 2, 3, or 4)]
- Type - type of shortcut destination (StartMenu, Desktop or AutoStart)
- Folder - program category
- FullFileName - full path to executable, if you use standard path %ProgramFolder%, you need write "%PE_Programs%\%ProgramFolder%\test.exe", %PE_Programs% will be automatically changed to program folder and you need change test.exe to right executable name.
- Title - program name
- Work Folder - program work folder (similar to rules of FullFileName)
- Parameters - running parameters
- IconFile - full path to icon file (similar to rules of FullFileName)
- StartMode - mode of program window
- 1 - normal window
- 2 - minimize
- 3 - maximize
- 4 - hide (not support at this time)
- AddAutoRun - adds programs to autostart, example: "AddAutoRun,"Test Program","test.exe","/test",1", description:
- first parameter - program name
- second parameter - executable file (will be searched in folder with program)
- third parameter - running parameters
- fourth parameter - parameter for starting program:
- 1 - program will be start in normal window and system will wait when program will be finished
- 2 - program will be start in normal window and system will not wait when program will be finished
- 3 - program will be start in hide window and system will wait when program will be finished
- 4 - program will be start in hide window and system will not wait when program will be finished
- AddPostConfig - starts the program after the drivers are installed and the network is initialized. The start will be canceled if the driver setup will be skipped. This function is added in VistaPE v12 beta 2. The command syntax is fully analogous to "AddAutoRun"
- associate_file - make file associations, example: "associate_file,doc" (registry will be mounted automatically)
- hive_load - mount all registry files, example: "hive_load,HKU"
- hive_unload - unmount all registry files, example: "hive_unload,HKU"
- Add_Asso - make file associations, example: "Add_Asso,doc" (registry will NOT be mounted automatically, it's more faster than associate_file when using many commands
- reg_add - adds entries in the register (must be mounted first), example: reg_add,0x1,"%reg%\Classes\filetype","test","1"
- CopyDrv - internal command for easier work with the standard drivers, for example: "CopyDrv,acpi.inf_c947c6d1". Added in VistaPE v12 beta 1
- RegAddBoot - during the boot process VistaPE can add/modify registry settings, it's requested for correction path to the programs. The command syntax is fully analogous to "RegWrite" command of WinBuilder. For example: "RegAddBoot,"HKLM",0x1,"SOFTWARE\Classes\expandfile\shell\uniextract\command","","%PE_Programs%\Universal Extractor\uniextract.exe %1"
- AddToPEShell - add the program to the shell's list and select default shell, syntax: "AddToPEShell,Program Name,path_to.exe,True" (if last parameter set to "True", the program will be used as default shell), example: "AddToPEShell,%ProgramTitle%"
Note: the programs from the autorun will be started during the boot process from "VistaPE Loader" after the default shell is launched and before all the drivers are installed and the network is initialized.
- pFileBox1 - path to folder with program (used as a option for CopyProgram command)
- pTextLabel1 - label for pFileBox1
- pCheckBox1 - destination settings (used as a option for RunFromRam command)
- True (selected) - program will be copied to the folder "Program Files" and will be placed in RAM if "vistape.wim" is used. All will be work more faster and you can change media during system work, but you need very many system memory with this method.
- False (not selected) - programs will be copied to the folder "Programs" and will be placed directly to media, it's request less memory but working not so fast and you can not change media when program is running and can not write to program folder.
Global variables
- %RegSoftware% (or %HIVE_HKU%) - registry hive with program settings (%VistaTemp%\windows\system32\config\software)
- %RegSystem% (or %HIVE_HKLM%) - registry hive with system settings (%VistaTemp%\windows\system32\config\system)
- %RegUser% (or %RegDefault%, or %HIVE_HKCU%) - registry hive with user settings (%VistaTemp%\windows\system32\config\default)
- %HIVE_BASE% - root for mounting registry hives
- %reg_temp% - name of folder for mounting registry (wb-hive)
- %reg%\ - used to simplify work with the registry (always %reg_temp%\)
- %VistaInfo% - file with setting for VistaPE and source (%ProjectDir%\script.project)
- %BootSRC% - mount point for vistape.wim (%BaseDir%\BootWimSrc)
- %InstallSRC% - mount point for install.wim (%BaseDir%\InstallWimSrc)
- %API% - file with API functions (%ProjectDir%\api.script)
- %LocaleScript% - file with locale functions (%ProjectDir%\locale.script)
- %Target_Prog% - target folder for all programs, used with files operation and creating shortcuts (Programs - by default all programs will be placed at media)
- %PE_Programs% - full path to program folder at target media, used only for shortcuts (!CD\Programs - by default all programs will be placed at media)
- %AutoStartMode% - default parameters for program window in autorun (1 - program will be start in normal window and system will be wait when program will be finished before start next program)
- %AutoStartParameters% - default parameters for starting program in autorun (is not recommended set this anything)
- %VPE_CFG% - file with VistaPE settings (vistape.cfg), can be placed in "windows\system32" folder or in root folder on any disks.
Description of vistape.cfg format
The file named vistape.cfg is to store the settings of VistaPE, autorun, shortcuts, postconfig etc. This file is processed by "VistaPE Loader" while loading the system. Firstly the settings are being loaded from "x:\windows\system32\vistape.cfg", then the configuration file is being searched on all the available disks. While the system is booted, VistaPE loader is scanning for new removable media, detecting the new vistape.cfg files and rebuilding schortcuts.
Example:
screen=800x600
defaultshell=BS Explorer
[shortcut]
Archivators|7-zip|%SystemDrive%\Program Files\7-zip\7zfm.exe||
System|BGInfo|%SystemDrive%\Program Files\BGInfo\Bginfo.exe||
Security\WindowsGate|After WindowsGate in Vista|%SystemDrive%\Program Files\WindowsGate\After Wingate in Vista.txt||
Security\WindowsGate|WindowsGate|%SystemDrive%\Program Files\WindowsGate\WindowsGate.exe||
System Information|Unknown Devices|%SystemDrive%\Program Files\UnknownDevices\UnknownDevices.exe||
QuickLaunch|Total Commander|%SystemDrive%\Program Files\totalcmd\totalcmd.exe||
Desktop|Total Commander|%SystemDrive%\Program Files\totalcmd\totalcmd.exe||
|Total Commander|%SystemDrive%\Program Files\totalcmd\totalcmd.exe||
System|Ruslat|%SystemRoot%\System32\ruslat.exe||
QuickLaunch|PENetCfg|%SystemDrive%\Program Files\penetcfg\PENetCfg.exe||
Network|PENetCfg|%SystemDrive%\Program Files\penetcfg\PENetCfg.exe||
Administrative Tools|Disk Management|%SystemRoot%\System32\mmc.exe||/b %SystemRoot%\System32\diskmgmt.msc
Administrative Tools|Computer Management|%SystemRoot%\System32\mmc.exe||/b %SystemRoot%\System32\compmgmt.msc
Network|Map Network Drive|%systemroot%\System32\rundll32.exe|%SystemDrive%\Program Files\Icons\networkhdd.ico|shell32.dll,SHHelpShortcuts_RunDLL Connect
System|Ext3 Installable|X:\Windows\system32\IfsDrives.cpl||
Disk Tools|Disk Partitioner|%SystemDrive%\Program Files\DiskPartitioner\DiskPartitioner.exe||
System|Device Manager|%SystemRoot%\system32\DevMan.exe||
[autorun]
wait|BGInfo|%SystemDrive%\Program Files\BGInfo\runBGinfo.exe
nowait|Ruslat|%SystemRoot%\System32\ruslat.exe
hidewait|IfsDrives|x:\windows\system32\net.exe start "IfsDrives"
hidewait|Ext2fs|x:\windows\system32\net.exe start "Ext2fs"
[registry]
"HKLM",0x1,"SOFTWARE\Classes\Drive\shellex\DragDropHandlers\7-Zip","","{23170F69-40C1-278A-1000-000100020000}"
"HKLM",0x1,"SOFTWARE\Classes\Directory\shellex\DragDropHandlers\7-Zip","","{23170F69-40C1-278A-1000-000100020000}"
"HKLM",0x1,"SOFTWARE\Classes\Directory\shellex\ContextMenuHandlers\7-Zip","","{23170F69-40C1-278A-1000-000100020000}"
"HKLM",0x1,"SOFTWARE\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}\InprocServer32","ThreadingModel","Apartment"
"HKLM",0x1,"SOFTWARE\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}\InprocServer32","","%SystemDrive%\Program Files\7-zip\7-zip.dll"
"HKLM",0x1,"SOFTWARE\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}","","7-Zip Shell Extension"
"HKLM",0x1,"SOFTWARE\Classes\*\shellex\ContextMenuHandlers\7-ZIP","","{23170F69-40C1-278A-1000-000100020000}"
"HKCR",0x1,"Folder\shell\Explore From Here\command","","explorer.exe ""%1"""
"HKCR",0x1,"AllFilesystemObjects\shellex\ContextMenuHandlers\MoveToMenu","","{C2FBB631-2971-11D1-A18C-00C04FD75D13}"
"HKCR",0x1,"AllFilesystemObjects\shellex\ContextMenuHandlers\CopyToMenu","","{C2FBB630-2971-11D1-A18C-00C04FD75D13}"
[association]
zip,%SystemDrive%\Program Files\7-zip\7zfm.exe
z,%SystemDrive%\Program Files\7-zip\7zfm.exe
wim,%SystemDrive%\Program Files\7-zip\7zfm.exe
tpz,%SystemDrive%\Program Files\7-zip\7zfm.exe
tgz,%SystemDrive%\Program Files\7-zip\7zfm.exe
tbz2,%SystemDrive%\Program Files\7-zip\7zfm.exe
tbz,%SystemDrive%\Program Files\7-zip\7zfm.exe
taz,%SystemDrive%\Program Files\7-zip\7zfm.exe
tar,%SystemDrive%\Program Files\7-zip\7zfm.exe
swm,%SystemDrive%\Program Files\7-zip\7zfm.exe
split,%SystemDrive%\Program Files\7-zip\7zfm.exe
rpm,%SystemDrive%\Program Files\7-zip\7zfm.exe
rar,%SystemDrive%\Program Files\7-zip\7zfm.exe
lzh,%SystemDrive%\Program Files\7-zip\7zfm.exe
lha,%SystemDrive%\Program Files\7-zip\7zfm.exe
iso,%SystemDrive%\Program Files\7-zip\7zfm.exe
gzip,%SystemDrive%\Program Files\7-zip\7zfm.exe
gz,%SystemDrive%\Program Files\7-zip\7zfm.exe
deb,%SystemDrive%\Program Files\7-zip\7zfm.exe
cpio,%SystemDrive%\Program Files\7-zip\7zfm.exe
cab,%SystemDrive%\Program Files\7-zip\7zfm.exe
bzip2,%SystemDrive%\Program Files\7-zip\7zfm.exe
bz2,%SystemDrive%\Program Files\7-zip\7zfm.exe
arj,%SystemDrive%\Program Files\7-zip\7zfm.exe
7z,%SystemDrive%\Program Files\7-zip\7zfm.exe
[shells]
Total Commander|totalcmd\totalcmd.exe
Explorer|%SystemDrive%\Windows\explorer.exe
BS Explorer|BSExplorer\Explorer.exe
[postconfig]
hidewait|Virtual Machine Additions Shared Folder Service|x:\windows\system32\net.exe start "Virtual Machine Additions Shared Folder Service"
hidewait|Virtual Machine Additions Services Application|x:\windows\system32\net.exe start "Virtual Machine Additions Services Application"
hidewait|Human Interface Device Access|x:\windows\system32\net.exe start "hidserv"
hidewait|Computer Browser|x:\windows\system32\net.exe start "Browser"
hidewait|User Profile Service|x:\windows\system32\net.exe start "ProfSvc"
hidewait|Server|x:\windows\system32\net.exe start "LanmanServer"
hidewait|DNS Client|x:\windows\system32\net.exe start "Dnscache"
Description of section [main]:
Here the general settings of VistaPE are stored
- screen - resolution, for example: "800x600"; if the value is "optimal", the system tries to define the optimal value itself.
- defaultshell - the name of the shell by default
Description of section [shells]:
Here is the description of every shell's settings. Syntax is "Program name|Path and options of launching", for example: "Explorer|%SystemDrive%\Windows\explorer.exe"
Description of section [shortcut]:
Here is the description of every program's shortcuts settings. Syntax is "Group|Name|Program|Shortcut|Options", for example: "Network|Map Network Drive|%systemroot%\System32\rundll32.exe|%SystemDrive%\Program Files\Icons\networkhdd.ico|shell32.dll,SHHelpShortcuts_RunDLL Connect".
The detailed description of the values:
- group - the name of the group for programs' shortcuts in "Start" menu, if the value is "Desktop" ("DS") or "QuickLaunch" ("QL") shortcuts will be placed in Desktop or QuickLaunch.
- name - full program name.
- program - the full or relative path to the program executable.
- shortcut - the path to the shortcut icon (not required).
- options - the options of program launching (may be absent).
Description of section [registry]:
Changing of registry settings, the syntax has full analogy to "RegWrite" command in WinBuilder.
Description of section [association]:
The files' association settings. Syntax is Extension,The path to the program", example: "7z,%SystemDrive%\Program Files\7-zip\7zfm.exe".
Description of section [autorun]:
Programs for autorun, starts immediately after the default shell is launched and before the drivers are installed and network initialized. For example: "hidewait|Ext2fs|x:\windows\system32\net.exe start "Ext2fs"".
The option contains three sections:
- Start option:
- wait - the program is launched in the standard window, before continue the job shutdown is waited for
- nowait - stabdart window, not waiting for the shutdown
- hidewait - hidden mode, waiting for the shutdown
- hidenowait - hidden mode, not waiting for the shutdown
- Program name
- Program path and parameters
Description of section [postconfig]:
Here is the description of programs that will be launched after the configuration of all the drivers is done and the network initialized. The syntax has full analogy to the section "autorun"
Note:
- It is not recommended to edit vistape.cfg directly, t here is an appropriate API command for everything.
- The number of shells is limited by 14.
- The path to any program may be full "x:\widows\system32\notepad.exe", or relative as well "totalcmd\totalcmd.exe", also it can contain the modifiers "%SystemDrive%\Program Files\7-zip\7zfm.exe"
- When the path is relative, the program is being searched in the root directory of the media, then in "Programs" folder, then "Program files", then "x:\Program Files" and "x:\Programs". If nothing is found the process is finished.
- Possible modifiers of the path to the program:
- %CDDrive% - The letter of the disk where the program is
- %SystemDrive% - always "X:"
- %SystemRoot% - "X:\Windows"
- !S32 - "X:\Windows\System32"
- !PFC - "%CDDrive%\Program Files"
- !PF - "X:\Program Files"
- !PDC - "%CDDrive%\Programs
- !PD - "X:\Programs"
- !CD - %CDDrive%
- !WD - %SystemRoot%
Recommendations for creating scripts
- Check program compatibility with VistaPE before creating script.
- Always, whenever possible, use the API functions.
- Read documentation for WinBuilder.
- After creating and testing a script, to share their achievements at the forum VistaPE, thus you make a huge contribution to the project to help others in writing scripts and honor support other users to optimize and improve your script.



