[Main]
Title=API
Description=API for VistaPE, you can not run this script directly.
Author=NightMan
Version=12
Date=14.10.2008
Contact=http://www.vistape.net
Credits=
Selected=None
Locked=false
Download_Level=0
level=1
Type=Script
Mandatory=True
#######################################################
#add registry setting during boot
#registry format is fully compatibility with WB
#RegAddBoot,"HKLM",0x1,"SOFTWARE\Test","Test key","Test Value"

[RegAdd_Boot]
IniWriteTextLine,"%VPE_CFG%","registry","#$q#1#$q#$c#2#$c#$q#3#$q#$c#$q#4#$q#$c#$q#5#$q"
#######################################################
#add program to PE Shell Swapper
#AddToPEShell,"Title","run.exe",True

[Add_To_PEShell]
#program patch
If,#2,Equal,"",Set,#2,%programFolder%\%ProgramExe%
If,#2,NotEqual,"",StrFormat,path,#2,%CPath%
If,#2,NotEqual,"",If,%CPath%,Equal,,Set,#2,%programFolder%\#2
#
If,#3,Equal,True,IniWrite,"%VPE_CFG%","main","defaultshell","#1"
IniWriteTextLine,"%VPE_CFG%","shells","#1|#2"
#######################################################
#Check VistaPE compatibility

[Compatible]
If,#1,Equal,"VistaPE",Message,"This program is not compatible with VistaPE! #$x#$xExiting..."
If,#1,Equal,"VistaPE",Exit,"Exiting..."
#######################################################
#extract files
//===>  Unpack,[Folder],[Archive zip rar 7z and some exe],[True],[%Target_Prog%],[%ProgramFolder%],[%programExe%]

[depack]
#folder with archive
If,#1,Equal,,Set,#1,Folder
#archive name
If,#2,Equal,,Set,#2,Depack_ALL_Files
#archive type
StrFormat,ext,#2,%Depack_Ext%
#target folder + check run from ram
IniRead,%VistaInfo%,"VistaInfo","ForceAllToRam","%ForceAllToRam%"
If,"%ForceAllToRam%",Equal,"Yes",Set,"%Target_Prog%","%TargetDir%\Program#$sFiles"
If,#4,Equal,,Set,#4,%Target_Prog%
If,#5,Equal,,Set,#5,%ProgramFolder%
#program name
If,#6,Equal,,Set,#6,%ProgramExe%
#make dir
ShellExecute,hide,"%WindowsDir%\System32\cmd.exe","/c mkdir #$q#4\#5#$q"
#check unpacked files
If,ExistFile,"%ScriptDir%\#5\#6",Run,%API%,Copy_Program,"%ScriptDir%\#5","#4\#5","#6"
If,NotExistFile,"%ScriptDir%\#5\#6",Run,%API%,Depack_And_Check_Ext,#1,#2,#3,#4,#5,#6

[Depack_And_Check_Ext]
Set,%AFolder%,#1
Set,%Archive%,#2
Set,%Target%,#4\#5
#
If,#2,Equal,Depack_ALL_Files,ExtractAllFiles,%ScriptFile%,%AFolder%,%Target%
If,#2,NotEqual,Depack_ALL_Files,ExtractFile,%ScriptFile%,%AFolder%,%Archive%,%Target%
#
If,%Depack_Ext%,Equal,".exe",run,%API%,Depack_Execute_Archive,#1,#2,#3,#4,#5,#6
If,%Depack_Ext%,NotEqual,".exe",run,%API%,Depack_Extract_Archive,#1,#2,#3,#4,#5,#6
#
#delete archive
If,%Archive%,NotEqual,Depack_ALL_Files,FileDelete,"%Target%\%Archive%"

[Depack_Execute_Archive]
Echo,"Executing archive file..."
ShellExecute,open,"#4\#5\#2","#3","#4\#5"

[Depack_Extract_Archive]
If,#2,NotEqual,Depack_ALL_Files,Echo,"Extracting archive file..."
If,#2,NotEqual,Depack_ALL_Files,ShellExecute,Hide,#$q%Tools%\7z.exe#$q,"x -y #$q#4\#5\#2#$q -o#$q#4\#5#$q"
#######################################################
#copy source folder

[Copy_Program]
#check run from ram
IniRead,%VistaInfo%,"VistaInfo","ForceAllToRam","%ForceAllToRam%"
If,"%ForceAllToRam%",Equal,"Yes",Set,"%Target_Prog%","%TargetDir%\Program#$sFiles"
Echo,"Copy program files..."
#destination folder
If,#2,Equal,,Set,%Target%,%Target_Prog%\%ProgramFolder%
If,#2,NotEqual,,Set,%Target%,#2
#executable
If,#3,Equal,,Set,#3,%ProgramExe%
If,NotExistFile,"#1\#3",Message,"The path you specified as your source is not valid! #$x#$xPlease select a valid source dir in the script configuration window..."
If,NotExistFile,"#1\#3",Exit,"Exiting..."
ShellExecute,hide,"%WindowsDir%\System32\cmd.exe","/c mkdir #$q%Target%#$q"
DirCopy,"#1\*.*","%Target%"
#######################################################
#run from ram configuration

[RunFrom_Ram]
If,#1,Equal,True,Set,"%Target_Prog%","%TargetDir%\Program#$sFiles"
If,#1,Equal,True,Set,"%PE_Programs%","#$pSystemDrive#$p\Program#$sFiles"
If,#1,Equal,True,Set,%VPE_CFG%,%VPECFG%
IniRead,%VistaInfo%,"VistaInfo","ForceAllToRam","%ForceAllToRam%"
If,"%ForceAllToRam%",Equal,"Yes",Set,%VPE_CFG%,%VPECFG%
If,"%ForceAllToRam%",Equal,"Yes",Set,"%Target_Prog%","%TargetDir%\Program#$sFiles"
If,"%ForceAllToRam%",Equal,"Yes",Set,"%PE_Programs%","#$pSystemDrive#$p\Program#$sFiles"
#######################################################
#copy one file from source

[expand_file]
IniRead,%VistaInfo%,"VistaInfo","Language","%DistLang%"
IniRead,%VistaInfo%,"VistaInfo","SystemFiles","%SystemFiles%"
If,ExistFile,"%SystemFiles%\Windows\System32\#1",FileCopy,"%SystemFiles%\Windows\System32\#1","%TargetDir%\Windows\System32"
If,ExistFile,"%SystemFiles%\Windows\System32\%DistLang%\#1.mui",DirMake,"%TargetDir%\Windows\System32\%DistLang%"
If,ExistFile,"%SystemFiles%\Windows\System32\%DistLang%\#1.mui",FileCopy,"%SystemFiles%\Windows\System32\%DistLang%\#1.mui","%TargetDir%\Windows\System32\%DistLang%"
If,ExistFile,"%SystemFiles%\Windows\System32\en-US\#1.mui",DirMake,"%TargetDir%\Windows\System32\en-US"
If,ExistFile,"%SystemFiles%\Windows\System32\en-US\#1.mui",FileCopy,"%SystemFiles%\Windows\System32\en-US\#1.mui","%TargetDir%\Windows\System32\en-US"
If,NotExistFile,"%TargetDir%\Windows\System32\#1",Beep,Error
If,NotExistFile,"%TargetDir%\Windows\System32\#1",Echo,"!!! Can not copy #1 file!!!
#######################################################
#copy one file from source - VistaPE Edition

[Require_Sys_File]
IniRead,%VistaInfo%,"VistaInfo","Language","%DistLang%"
IniRead,%VistaInfo%,"VistaInfo","SystemFiles","%SystemFiles%"
StrFormat,filename,#1,%CFileName%
StrFormat,path,#1,%CPath%
DirMake,"%TargetDir%\%CPath%"
DirMake,"%TargetDir%\%CPath%\%DistLang%"
DirMake,"%TargetDir%\%CPath%en_US"
If,ExistFile,"%SystemFiles%\%CPath%%CFileName%",FileCopy,"%SystemFiles%\%CPath%%CFileName%","%TargetDir%\%CPath%"
If,ExistFile,"%SystemFiles%\%CPath%%DistLang%\%CFileName%.mui",FileCopy,"%SystemFiles%\%CPath%%DistLang%\%CFileName%.mui","%TargetDir%\%CPath%%DistLang%"
If,ExistFile,"%SystemFiles%\%CPath%en-US\%CFileName%.mui",FileCopy,"%SystemFiles%\%CPath%en-US\%CFileName%.mui","%TargetDir%\%CPath%en-US"
If,NotExistFile,"%TargetDir%\#1",Beep,Error
If,NotExistFile,"%TargetDir%\#1",Echo,"!!! Can not copy #1 file!!!
#######################################################
#AutoRun

[Add_Post_Config]
//AddPostConfig,%ProgramTitle%,%ProgramExe%,%AutoStartParameters%,%AutoStartMode%
IniRead,%VistaInfo%,"VistaInfo","ForceAllToRam","%ForceAllToRam%"
If,"%ForceAllToRam%",Equal,"Yes",Set,%VPE_CFG%,%VPECFG%
If,"%ForceAllToRam%",Equal,"Yes",Set,"%PE_Programs%","#$pSystemDrive#$p\Program#$sFiles"
If,#4,Equal,"",Set,#4,wait
If,#4,Equal,"1",Set,#4,wait
If,#4,Equal,"2",Set,#4,nowait
If,#4,Equal,"3",Set,#4,hidewait
If,#4,Equal,"4",Set,#4,hidenowait
#program patch
If,#2,Equal,"",Set,#2,%PE_Programs%\%programFolder%\%ProgramExe%
If,#2,NotEqual,"",StrFormat,path,#2,%CPath%
If,#2,NotEqual,"",If,%CPath%,Equal,,Set,#2,%PE_Programs%\%programFolder%\#2
#
If,#1,Equal,"",Set,#1,%ProgramTitle%
#
IniWriteTextLine,"%VPE_CFG%","postconfig","#4|#1|#2#$s#3"
#######################################################
#AutoRun

[Add_Auto_Run]
//AddAutoRun,%ProgramTitle%,%ProgramExe%,%AutoStartParameters%,%AutoStartMode%
IniRead,%VistaInfo%,"VistaInfo","ForceAllToRam","%ForceAllToRam%"
If,"%ForceAllToRam%",Equal,"Yes",Set,%VPE_CFG%,%VPECFG%
If,"%ForceAllToRam%",Equal,"Yes",Set,"%PE_Programs%","#$pSystemDrive#$p\Program#$sFiles"
If,#4,Equal,"",Set,#4,wait
If,#4,Equal,"1",Set,#4,wait
If,#4,Equal,"2",Set,#4,nowait
If,#4,Equal,"3",Set,#4,hidewait
If,#4,Equal,"4",Set,#4,hidenowait
#program patch
If,#2,Equal,"",Set,#2,%PE_Programs%\%programFolder%\%ProgramExe%
If,#2,NotEqual,"",StrFormat,path,#2,%CPath%
If,#2,NotEqual,"",If,%CPath%,Equal,,Set,#2,%PE_Programs%\%programFolder%\#2
#
If,#1,Equal,"",Set,#1,%ProgramTitle%
#
IniWriteTextLine,"%VPE_CFG%","autorun","#4|#1|#2#$s#3"
#######################################################
#read system configuration

[Read_ENV]
IniRead,%VistaInfo%,"VistaInfo","Language","%DistLang%"
IniRead,%VistaInfo%,"VistaInfo","SourceDir","%SDIR%"
IniRead,%VistaInfo%,"VistaInfo","SourceType","%SourceType%"
IniRead,%VistaInfo%,"VistaInfo","WimTools","%WimTools%"
IniRead,%VistaInfo%,"VistaInfo","SystemFiles","%SystemFiles%"
If,"%WimTools%",Equal,"ImageX",IniRead,%VistaInfo%,"VistaInfo","imagex","%IMAGEX%"
IniRead,%VistaInfo%,"VistaInfo","BuildModel","%BuildModel%"
IniRead,%VistaInfo%,"VistaInfo","Shell","%Shell%"
IniRead,%VistaInfo%,"VistaInfo","ScreenResolution","%ScreenResolution%"
IniRead,%VistaInfo%,"VistaInfo","Locale","%Locale%"
IniRead,%VistaInfo%,"VistaInfo","SysType","%SysType%"
IniRead,%VistaInfo%,"VistaInfo","GrubSkin","%GrubSkin%"
IniRead,%VistaInfo%,"VistaInfo","ForceAllToRam","%ForceAllToRam%"
If,"%SourceType%",Equal,"",run,%API%,NotConfigured
IniRead,%VistaInfo%,"VistaInfo","DllSrc","%DllSrc%"
IniRead,%VistaInfo%,"VistaInfo","WAIKDir","%WAIKDir%"
#######################################################
#shortcuts
#Add_Shortcut,[Type],[Folder],[FullFileName],[Title],[Work Folder],[Parameters],[IconFile( .ico .exe)],[StartMode(1, 2, 3, or 4)]
#Category|Program Title|Path|Icon|Parameters

[AddShortcut]
#check run from ram
IniRead,%VistaInfo%,"VistaInfo","ForceAllToRam","%ForceAllToRam%"
If,"%ForceAllToRam%",Equal,"Yes",Set,%VPE_CFG%,%VPECFG%
If,"%ForceAllToRam%",Equal,"Yes",Set,"%Target_Prog%","%TargetDir%\Program#$sFiles"
If,"%ForceAllToRam%",Equal,"Yes",Set,"%PE_Programs%","#$pSystemDrive#$p\Program#$sFiles"
#category
If,#1,Equal,Desktop,Set,#2,Desktop
If,#1,Equal,QuickLaunch,Set,#2,QuickLaunch
If,#1,Equal,Autorun,Set,#2,Autorun
If,#1,Equal,AutoStart,Set,#2,Autorun
#If,#2,Equal,,StrFormat,filename,%Scriptdir%,#2
#pach to program
If,#3,Equal,"",Set,#3,%PE_Programs%\%programFolder%\%ProgramExe%
If,#3,NotEqual,"",StrFormat,path,#3,%CPath%
If,#3,NotEqual,"",If,%CPath%,Equal,,Set,#3,%PE_Programs%\%programFolder%\#3
#program title
If,#4,Equal,,Set,#4,%ProgramTitle%
#
#process
IniWriteTextLine,"%VPE_CFG%","shortcut","#2|#4|#3|#7|#6"
#######################################################
#file association

[do_associate]
echo,"Associate . #1 file"
IniRead,%VistaInfo%,"VistaInfo","ForceAllToRam","%ForceAllToRam%"
If,"%ForceAllToRam%",Equal,"Yes",Set,%VPE_CFG%,%VPECFG%
If,#2,Equal,"",Set,#2,%PE_Programs%\%programFolder%\%ProgramExe%
If,#2,NotEqual,"",StrFormat,path,#2,%CPath%
If,#2,NotEqual,"",If,%CPath%,Equal,,Set,#2,%PE_Programs%\%programFolder%\#2
IniWriteTextLine,"%VPE_CFG%","association","#1#$c#2"

[reg_hiveload]
Set,"%hive_file%","%HIVE_#1%"
echo,"Loading #1 hive.."
echo,"Loading hive from %hive_file%"
RegHiveLoad,%reg_temp%,%hive_file%

[reg_hiveunload]
echo,"Unloading %reg_temp%"
RegHiveUnLoad,%reg_temp%
#######################################################
#copy drivers from source

[Copy_Drv]
If,ExistDir,"%BootSRC%\Windows\System32\DriverStore\FileRepository\#1",run,%API%,Copy_Drv_Process,"%BootSRC%\Windows\System32\DriverStore\FileRepository\#1"
If,NotExistDir,"%BootSRC%\Windows\System32\DriverStore\FileRepository\#1",If,ExistDir,"%InstallSRC%\Windows\System32\DriverStore\FileRepository\#1",run,%API%,Copy_Drv_Process,"%InstallSRC%\Windows\System32\DriverStore\FileRepository\#1"

[Copy_Drv_Process]
FileCopy,"#1\*.sys","%TargetDir%\Windows\System32\Drivers"
FileCopy,"#1\*.dll","%TargetDir%\Windows\System32"
FileCopy,"#1\*.inf","%TargetDir%\Windows\Inf"
#######################################################
#by Markus Debus

[UnMountWim]
IniRead,%VistaInfo%,"VistaInfo","WimTools","%WimTools%"
echo,"UnMountig WIM files..."
If,"%WimTools%",Equal,"ImageX",Run,"%API%",UnMountImagex
If,"%WimTools%",Equal,"WimUtil",Run,"%API%",UnMountWimutil

[UnMountWimutil]
If,ExistDir,"%BootSRC%\Windows",ShellExecute,Hide,"#$q%tools%\wimutil\wimutil.exe#$q","unmount #$q%BootSRC%#$q"
If,ExistDir,"%InstallSRC%\Windows",ShellExecute,Hide,"#$q%tools%\wimutil\wimutil.exe#$q","unmount #$q%InstallSRC%#$q"

[UnMountImagex]
If,ExistDir,"%BootSRC%\Windows",ShellExecute,Hide,"#$q%imagex%#$q","/unmount #$q%BootSRC%#$q"
If,ExistDir,"%InstallSRC%\Windows",ShellExecute,Hide,"#$q%imagex%#$q","/unmount #$q%InstallSRC%#$q"

[Clean]
ReadENV
If,#1,Equal,DONE,Begin
If,"%pCheckBox2%",Equal,"True",Run,"%API%",UnMountWim
If,"%pCheckBox1%",Equal,"True",Message,"Build sucessfull.",INFORMATION
End
If,#1,Equal,STOP,Begin
If,"%pCheckBox4%",Equal,"True",Run,"%API%",UnMountWim
If,"%pCheckBox3%",Equal,"True",Message,"Build stopped by user.",INFORMATION
End
If,#1,Equal,ERROR,Begin
If,"%pCheckBox6%",Equal,"True",Run,"%API%",UnMountWim
If,"%pCheckBox5%",Equal,"True",Message,"Build stopped due to an error.",INFORMATION
End
If,#1,Equal,COMMAND,Begin
If,"%pCheckBox8%",Equal,"True",Run,"%API%",UnMountWim
If,"%pCheckBox7%",Equal,"True",Message,"Build stopped by script command.",INFORMATION
End
If,#1,Equal,EXCEPTION,Begin
If,"%pCheckBox10%",Equal,"True",Run,"%API%",UnMountWim
If,"%pCheckBox9%",Equal,"True",Message,"Build stopped by exception.",INFORMATION
End
#######################################################
#######################################################
#######################################################

[Interface]
pBevel1=pBevel1,1,12,8,26,255,65
pBevel2=pBevel2,1,12,272,26,257,65
pBevel3=pBevel2,1,12,8,97,255,65
pBevel4=pBevel2,1,12,8,170,256,65
pBevel5=pBevel2,1,12,272,97,257,65
pTextLabel1="The build was sucessfull (DONE):",1,1,14,29,179,18,8,Normal
pTextLabel2="The user aborted build (STOP):",1,1,278,30,172,18,8,Normal
pTextLabel3="A script command failed (ERROR):",1,1,14,101,181,18,8,Normal
pTextLabel4="A command aborted the build (COMMAND):",1,1,280,101,230,18,8,Normal
pTextLabel5="A syntax error aborted the build (EXCEPTION):",1,1,15,175,230,18,8,Normal
pCheckBox1="Inform me with a messagebox",1,3,21,47,171,17,True
pCheckBox2="Unmount the WIM files (should always be on)",1,3,21,67,239,18,True
pCheckBox3="Inform me with a messagebox",1,3,284,48,171,17,True
pCheckBox4="Unmount the WIM files (should always be on)",1,3,284,67,237,18,True
pCheckBox5="Inform me with a messagebox",1,3,22,121,171,17,True
pCheckBox6="Unmount the WIM files (should always be on)",1,3,22,141,236,18,True
pCheckBox7="Inform me with a messagebox",1,3,285,119,171,17,True
pCheckBox8="Unmount the WIM files (should always be on)",1,3,285,139,239,18,True
pCheckBox9="Inform me with a messagebox",1,3,21,192,171,21,True
pCheckBox10="Unmount the WIM files (should always be on)",1,3,21,214,238,18,True
pTextLabel6="OnExit Settings:",1,1,12,6,230,18,8,Bold

[InterfaceEncoded]

[AuthorEncoded]
VistaPE-11-Small.gif=1Kb,1Kb
Logo=VistaPE-11-Small.gif

[EncodedFile-AuthorEncoded-VistaPE-11-Small.gif]
lines=0
0=R0lGODlhWQAjANU/AOmRkPzwypG12Pj39PbVZuysq05YZvCbUcfa67HL4/jgkOuILKzKo0eKMuR7dmmayeZ0JId3SPKuE3GlYJKZq+6cF1xqh9xPSfSzjtk7NvPHM/rpr9OtKsrP15qyffLBtWE1UO2KFzh5uKePOPnl3i89YfKqf+m5IjtIYZsvPvXLyfbY1+Tn6u+gc/345Nbg7LK4xneDmvnZx0qGvuFmYeTt86KquuBeYZa9iyo8YdYyKdYoLB9psPLCIP///////yH5BAEAAD8ALAAAAABZACMAAAb/wJ9wSCwahz5fZ8lsspJQ33FKrVqHqmy2AOh6v13abfyx5HKlHCpm6zyj17hxIKvLhnS7nSRc7f6AgYKDOzBoaDEDUnKMUxghFZEVCy10kJKRB0IOhJ2ENoclHY2kRxgSCwcHC5ELMpmqqiZCGZ62gAUoaRaLpb4/p5pCH5EmFSFHHxDLzKyYkSc90tIQfxkFNjYsjUm/Q8FEBxIHx0cDGtPp6usngSln21c+AxsEvb/gQ+TkyEcK6wDVLQgEIocFOf+k3fOV7wcJSC2O6ZHB54eLgBh71AJ0xgbCaQtLBauDgVUIFRUkPMMwhEA6DhFiKpipIIDNAC3cwUMSBcqQ/4Q9QpI6pTLlJBKvQsRS9WHIxXQGSpSAceRCoAgUYET5AICGVxoAVHQDKlRIz25GTqU6YKLpj6RVXE6LcOZgET+BKDTYi2PFBR2AA+v4QFNuD5o0k9QQ8GAGj8ciHiRAK6ThELhUAqQ7geLMKCIA3OltMGFFBsAXvDi4gCGjNA0vHjyeTZvHjBe9LAvBTMVwD7o5YhTZ+KfE6Bp/dTg4q9l1jwSzZzwQwFjEbBEvvo0zwnvKhpdncsT78UGQcdIFUIcccNPwzZsDRCRQtCiJgOiLdL+NFKJ/fwhGoDPXGRQMQQNBOeiFgwOAAVCWEGQV4ZMRPtz3WAKVKcWdfxwCWP/Ed9OMcAYKA/wwgHkJNsAADQ0++EOEjPhgHQ8PuMjIOVClUWAB7kgFQwMLqvcgjHL4IBsPItjICFA9iJiDAT8Qt0NBKPhAmgqBLVcWkXJYyIMUL1gg5phklmlBgXOoo0uC5pUQg5UqMohaARP+BJIVUbyAwJE8lDhAE4AG2kF2R/gmYgkg6JRDB3A2wIKcgGUAAAmUcUmEDzUk0FhtsyHgjRFPSXOCVCUgCGWjE/jwQXKBAaAIhHdKGBunnHr6aRG+AZcCRwn+gCoUH0CqwwUrSGFphbTNIEACCDTLp623DtGcNBycUeoO7+SQ3a9m+UACpDcYG6tZfD5QA2U/eAn/bbRC5IrGrgVB6etepN2TRHqA0UmkD9A9JoBQ6rJLBIjUnpEogWbRmyqFLCrnw76O2VZWwAIPIaA0Bhi807x7LSwhAIDR8PC4Ncz27xQUV/wDwU2mURcSCofkA8g6iEwkAiZPgexj61Z8cQ+ddQRzAx54fKmcDgLlwhA4+6vzjDz0LDCTTooHc19v8LRCYMUSvMEiJT9WI4VeRq0yHhePatClKt6QgQMfFOuDCjTr4KBF02jwqg8RR92LfbVJLXCuU7G9tWCI292ND4ZpQMBMTfvbLAICWDdD2GafLUSoPVRbIswMqLAa4m+L1UsAP0ujQL+0zqBIp5q3lI4HEjJgKrsiJGgh90I+BOBbD/YgADVkk/kaMYaxJ59EABsosEEAeSawLG71weFLEAA7eJwTCcssLkkMcNU1NNQNzk3MydFLz0xjGAUjBfCy4pePC/p4l5EBAFzPCVvZ0RNqAQAAAAIAAAAsAAAADQUAAAAAAAABAAAAAAAAAAAAAAA

