mirror of
https://github.com/PhoenixPE/PhoenixPE.git
synced 2025-09-16 18:18:04 +02:00
PhoenixAPI updates:
Added FileSearch command to the PhoenixAPI to allow searching for a specific file(s) in a path. Fixed an issue with FileCopyEx that would case the file to be copied incorrectly if the destination directory did not exist.
This commit is contained in:
@@ -35,8 +35,8 @@ Author=Homes32
|
||||
Level=5
|
||||
Selected=False
|
||||
Mandatory=False
|
||||
Version=1.0.1.0
|
||||
Date=2022-12-24
|
||||
Version=1.1.0.0
|
||||
Date=2023-1-04
|
||||
|
||||
[Variables]
|
||||
%ProgramFolder%="Acronis CyberProtect"
|
||||
@@ -329,35 +329,37 @@ FileCopy,"%TargetPrograms%\%ProgramFolder%\bootmenu.bin","%TargetPrograms%\%Prog
|
||||
// Parameters.....:
|
||||
// Return values..:
|
||||
// Author.........: Homes32
|
||||
// Remarks........: Acronis Cyber Protect is downloaded as a compressed.exe that contains a .msi installer, that contains a WinPE.zip file that contains the exe.
|
||||
// Remarks........: Acronis Cyber Protect is downloaded as a compressed.exe that contains a .msi installer,
|
||||
// that contains a zip file pretending to be a .dll, which contains a WinPE.zip file that contains the exe files.
|
||||
// Related........:
|
||||
// ===============================================================================================================================
|
||||
[DownloadProgram]
|
||||
Echo,"Downloading %ScriptTitle%..."
|
||||
WebGet,"%DownloadURL%","%ProgramsCache%\%ProgramFolder%\%SetupFile%",NOERR
|
||||
WebGet,"%DownloadURL%","%ProjectTemp%\%ProgramFolder%\%SetupFile%",NOERR
|
||||
If,Not,#r,Equal,200,Halt,"Failed to download [%SetupFile%]: The code returned was [#r]."
|
||||
|
||||
// The name of the CAB file inside the .msi to extract. This occasionally changes with new releases and needs to be updated.
|
||||
Set,%CAB%,"_*_52D78812FFC93DDE133DECBB0875BCA0"
|
||||
|
||||
// Extract the .msi installer
|
||||
Echo,"Extracting installer..."
|
||||
7z,"e -y #$q%ProgramsCache%\%ProgramFolder%\%SetupFile%#$q AcronisCyberProtectHomeOffice.msi -o#$q%ProjectTemp%\%ProgramFolder%#$q"
|
||||
7z,"e -y #$q%ProjectTemp%\%ProgramFolder%\%SetupFile%#$q AcronisCyberProtectHomeOffice.msi -o#$q%ProjectTemp%\%ProgramFolder%#$q"
|
||||
If,Not,#r,Equal,0,Halt,"Failed to extract .msi from [%SetupFile%]: The code returned was [#r]."
|
||||
|
||||
// Extract compressed WinPE.zip from .msi installer
|
||||
Echo,"Extracting WinPE.zip from installer..."
|
||||
7z,"e -y #$q%ProjectTemp%\%ProgramFolder%\AcronisCyberProtectHomeOffice.msi#$q %CAB% -o#$q%ProjectTemp%\%ProgramFolder%#$q"
|
||||
If,Not,#r,Equal,0,Halt,"Failed to extract from [AcronisCyberProtectHomeOffice.msi]: The code returned was [#r]."
|
||||
MSIExtract,"%ProjectTemp%\%ProgramFolder%\AcronisCyberProtectHomeOffice.msi","%ProjectTemp%\%ProgramFolder%"
|
||||
|
||||
// Unpack compressed WinPE.zip
|
||||
Echo,"Decompressing WinPE.zip..."
|
||||
7z,"e -y #$q%ProjectTemp%\%ProgramFolder%\%CAB%#$q WinPE.zip -o#$q%ProgramsCache%\%ProgramFolder%#$q"
|
||||
If,Not,#r,Equal,0,Halt,"Failed to extract from [%CAB%]: The code returned was [#r]."
|
||||
// Find the full path to WinPE_resources.dll
|
||||
Echo,"Decompressing WinPE Resources..."
|
||||
FileSearch,"%ProjectTemp%\%ProgramFolder%","WinPE_resources.dll"
|
||||
If,#r,Equal,"",Halt,"Failed to find [WinPE_resources.dll]: The code returned was [#r]."
|
||||
Else,List,Get,#r,1,%WinPEResPath%
|
||||
|
||||
// Unpack compressed WinPE.zip from WinPE_resources.dll
|
||||
7z,"e -y #$q%WinPEResPath%#$q WinPE.zip -o#$q%ProgramsCache%\%ProgramFolder%#$q"
|
||||
If,Not,#r,Equal,0,Halt,"Failed to extract WinPE.zip from [%WinPEResPath%]: The code returned was [#r]."
|
||||
|
||||
// Cleanup
|
||||
Set,%WinPEResPath%,Nil
|
||||
DirDeleteEx,"%ProjectTemp%\%ProgramFolder%"
|
||||
FileDeleteEx,"%ProgramsCache%\%ProgramFolder%\%SetupFile%"
|
||||
|
||||
[#ToggleLicenseReg#]
|
||||
// ===============================================================================================================================
|
||||
|
@@ -38,8 +38,8 @@ Author=Homes32
|
||||
Level=5
|
||||
Selected=False
|
||||
Mandatory=False
|
||||
Version=1.0.2.0
|
||||
Date=2022-12-24
|
||||
Version=1.1.0.0
|
||||
Date=2023-11-04
|
||||
|
||||
[Variables]
|
||||
%ProgramFolder%="TrueImage2021"
|
||||
@@ -337,30 +337,31 @@ FileCopy,"%TargetPrograms%\%ProgramFolder%\bootmenu.bin","%TargetPrograms%\%Prog
|
||||
// ===============================================================================================================================
|
||||
[DownloadProgram]
|
||||
Echo,"Downloading %ScriptTitle%..."
|
||||
WebGet,"%DownloadURL%","%ProgramsCache%\%ProgramFolder%\%SetupFile%",NOERR
|
||||
WebGet,"%DownloadURL%","%ProjectTemp%\%ProgramFolder%\%SetupFile%",NOERR
|
||||
If,Not,#r,Equal,200,Halt,"Failed to download [%SetupFile%]: The code returned was [#r]."
|
||||
|
||||
// The name of the CAB file inside the .msi to extract. This occasionally changes with new releases and needs to be updated.
|
||||
Set,%CAB%,"_57_52D78812FFC93DDE133DECBB0875BCA0"
|
||||
|
||||
// Extract the .msi installer
|
||||
Echo,"Extracting installer..."
|
||||
7z,"e -y #$q%ProgramsCache%\%ProgramFolder%\%SetupFile%#$q AcronisTrueImage.msi -o#$q%ProjectTemp%\%ProgramFolder%#$q"
|
||||
7z,"e -y #$q%ProjectTemp%\%ProgramFolder%\%SetupFile%#$q AcronisTrueImage.msi -o#$q%ProjectTemp%\%ProgramFolder%#$q"
|
||||
If,Not,#r,Equal,0,Halt,"Failed to extract .msi from [%SetupFile%]: The code returned was [#r]."
|
||||
|
||||
// Extract compressed WinPE.zip from .msi installer
|
||||
Echo,"Extracting WinPE.zip from installer..."
|
||||
7z,"e -y #$q%ProjectTemp%\%ProgramFolder%\AcronisTrueImage.msi#$q %CAB% -o#$q%ProjectTemp%\%ProgramFolder%#$q"
|
||||
If,Not,#r,Equal,0,Halt,"Failed to extract from [AcronisTrueImage.msi]: The code returned was [#r]."
|
||||
MSIExtract,"%ProjectTemp%\%ProgramFolder%\AcronisTrueImage.msi","%ProjectTemp%\%ProgramFolder%"
|
||||
|
||||
// Unpack compressed WinPE.zip
|
||||
Echo,"Decompressing WinPE.zip..."
|
||||
7z,"e -y #$q%ProjectTemp%\%ProgramFolder%\%CAB%#$q WinPE.zip -o#$q%ProgramsCache%\%ProgramFolder%#$q"
|
||||
If,Not,#r,Equal,0,Halt,"Failed to extract from [%CAB%]: The code returned was [#r]."
|
||||
// Find the full path to WinPE_resources.dll
|
||||
Echo,"Decompressing WinPE Resources..."
|
||||
FileSearch,"%ProjectTemp%\%ProgramFolder%","WinPE_resources.dll"
|
||||
If,#r,Equal,"",Halt,"Failed to find [WinPE_resources.dll]: The code returned was [#r]."
|
||||
Else,List,Get,#r,1,%WinPEResPath%
|
||||
|
||||
// Unpack compressed WinPE.zip from WinPE_resources.dll
|
||||
7z,"e -y #$q%WinPEResPath%#$q WinPE.zip -o#$q%ProgramsCache%\%ProgramFolder%#$q"
|
||||
If,Not,#r,Equal,0,Halt,"Failed to extract WinPE.zip from [%WinPEResPath%]: The code returned was [#r]."
|
||||
|
||||
// Cleanup
|
||||
Set,%WinPEResPath%,Nil
|
||||
DirDeleteEx,"%ProjectTemp%\%ProgramFolder%"
|
||||
FileDeleteEx,"%ProgramsCache%\%ProgramFolder%\%SetupFile%"
|
||||
|
||||
[#ToggleLicenseReg#]
|
||||
// ===============================================================================================================================
|
||||
|
@@ -32,8 +32,8 @@
|
||||
Title=PhoenixPE API
|
||||
Author=Homes32
|
||||
Description=PhoenixPE scripting support library.
|
||||
Version=1.7.0.0
|
||||
Date=2023-01-15
|
||||
Version=1.8.0.0
|
||||
Date=2023-09-21
|
||||
Level=0
|
||||
Selected=None
|
||||
|
||||
@@ -60,6 +60,7 @@ PinShortcut=Run,%API%,_PhoenixAPI_PinShortcut
|
||||
DirDeleteEx=Run,%API%,_PhoenixAPI_DirDeleteEx
|
||||
FileCopyEx=Run,%API%,_PhoenixAPI_FileCopyEx
|
||||
FileDeleteEx=Run,%API%,_PhoenixAPI_FileDeleteEx
|
||||
FileSearch=Run,%API%,_PhoenixAPI_FileSearch
|
||||
InnoCleanup=Run,%API%,_PhoenixAPI_InnoCleanup
|
||||
InnoRename=Run,%API%,_PhoenixAPI_InnoRename
|
||||
|
||||
@@ -743,6 +744,8 @@ System,EndLocal
|
||||
// Return values..:
|
||||
// Author.........: Homes32
|
||||
// Remarks........: Wildcards are not supported. If you need wildcards use FileCopy instead.
|
||||
// Note: It's NOT safe to blindly copy .mun files here as we have no idea if any Windows directories exist
|
||||
// on the drive we are copying from or if they match our source/arch.
|
||||
// Related........:
|
||||
// ===============================================================================================================================
|
||||
[_PhoenixAPI_FileCopyEx]
|
||||
@@ -754,24 +757,23 @@ If,#2,Equal,"",Halt,"FileCopyEx Syntax Error: Destination was not specified."
|
||||
GetParam,1,%SrcFile%
|
||||
GetParam,2,%DestPath%
|
||||
|
||||
StrFormat,Pos,%SrcFile%,*,%WildCard%
|
||||
If,Not,%WildCard%,Equal,0,Halt,"FileCopyEx Syntax Error: Wildcards are not supported."
|
||||
StrFormat,Pos,%SrcFile%,?,%WildCard%
|
||||
If,Not,%WildCard%,Equal,0,Halt,"FileCopyEx Syntax Error: Wildcards are not supported."
|
||||
ForEach,%WildCard%,"*|?",Begin
|
||||
StrFormat,Pos,%SrcFile%,%WildCard%,%WildCardPos%
|
||||
If,Not,%WildCardPos%,Equal,0,Halt,"FileCopyEx Syntax Error: Wildcards are not supported."
|
||||
End
|
||||
|
||||
StrFormat,CTrim,%DestPath%,"\",%DestPath%
|
||||
|
||||
If,Not,ExistDir,%DestPath%,DirMake,%DestPath%
|
||||
FileCopy,%SrcFile%,%DestPath%
|
||||
|
||||
StrFormat,FileName,%SrcFile%,%Filename%
|
||||
StrFormat,Split,%DestPath%,"\",1,%DriveLtr%
|
||||
If,ExistFile,"%DriveLtr%\Windows\SystemResources\%Filename%.mun",FileCopy,"%DriveLtr%\Windows\SystemResources\%Filename%.mun",APPEND
|
||||
|
||||
StrFormat,FileName,%SrcFile%,%FileName%
|
||||
StrFormat,Ext,%SrcFile%,%FileExt%
|
||||
StrFormat,DirPath,%SrcFile%,%SrcDirPath%
|
||||
StrFormat,DirPath,%DestPath%,%DestDirPath%
|
||||
StrFormat,DirPath,"%DestPath%\",%DestDirPath%
|
||||
|
||||
ForEach,%Language%,%SourceFallbackLang%,Begin
|
||||
If,%FileExt%,Equal,.msc,FileCopy,"%SrcDirPath%%Language%\%FileName%","%DestPath%\%Language%\%FileName%"
|
||||
If,%FileExt%,Equal,".msc",FileCopy,"%SrcDirPath%%Language%\%FileName%","%DestPath%\%Language%\%FileName%"
|
||||
Else,If,ExistFile,"%SrcDirPath%%Language%\%FileName%.mui",FileCopy,"%SrcDirPath%%Language%\%FileName%.mui","%DestDirPath%%Language%\%FileName%.mui"
|
||||
End
|
||||
|
||||
@@ -839,7 +841,7 @@ If,%Action%,Equal,"AppendList",Begin
|
||||
If,Not,ExistFile,%BulkFileList%,FileCreateBlank,%BulkFileList%
|
||||
TXTAddLine,%BulkFileList%,%GLOB%,APPEND
|
||||
TXTAddLine,%BulkFileList%,\Windows\SystemResources\%FileName%.mun,APPEND
|
||||
If,%ExtractMui%,Equal,True,ForEach,%Language%,%SourceFallbackLang%,Run,%API%,__PhoenixAPI_RequireFileEx_ProcessMUI,%GLOB%,%Language%,%BulkFileList%
|
||||
If,%ExtractMui%,Equal,True,ForEach,%Language%,%SourceFallbackLang%,Run,%API%,__PhoenixAPI_RequireFileEx_Process_MUI,%GLOB%,%Language%,%BulkFileList%
|
||||
End
|
||||
Else,If,%Action%,Equal,"ExtractFile",Begin
|
||||
Echo,"Extracting required file(s) [%GLOB%]..."
|
||||
@@ -847,7 +849,7 @@ Else,If,%Action%,Equal,"ExtractFile",Begin
|
||||
If,Not,ExistFile,%SingleFileList%,FileCreateBlank,%SingleFileList%
|
||||
TXTAddLine,%SingleFileList%,%GLOB%,APPEND
|
||||
TXTAddLine,%SingleFileList%,\Windows\SystemResources\%FileName%.mun,APPEND
|
||||
If,%ExtractMui%,Equal,True,ForEach,%Language%,%SourceFallbackLang%,Run,%API%,__PhoenixAPI_RequireFileEx_ProcessMUI,%GLOB%,%Language%,%SingleFileList%
|
||||
If,%ExtractMui%,Equal,True,ForEach,%Language%,%SourceFallbackLang%,Run,%API%,__PhoenixAPI_RequireFileEx_Process_MUI,%GLOB%,%Language%,%SingleFileList%
|
||||
WimExtractBulk,%SourceInstallWim%,%SourceInstallWimImage%,%SingleFileList%,%TargetDir%,NOACL,NOATTRIB,NOERR,NOWARN
|
||||
FileDeleteEx,%SingleFileList%
|
||||
End
|
||||
@@ -861,11 +863,11 @@ Else,Halt,"RequireFileEx Syntax Error: Invalid Action [#1]."
|
||||
|
||||
System,EndLocal
|
||||
|
||||
[#__PhoenixAPI_RequireFileEx_ProcessMUI#]
|
||||
[#__PhoenixAPI_RequireFileEx_Process_MUI#]
|
||||
// ===============================================================================================================================
|
||||
// Name...........: RequireFileEx_ProcessMUI
|
||||
// Name...........: RequireFileEx_Process_MUI
|
||||
// Description....: Extract a file's .mui from Install.wim
|
||||
// Syntax.........: RequireFileEx_ProcessMUI,<FilePath>,<Language>,<ListFile>
|
||||
// Syntax.........: RequireFileEx_Process_MUI,<FilePath>,<Language>,<ListFile>
|
||||
// Parameters.....: #1 FilePath - Path to the file relative to the root of Install.wim
|
||||
// #2 Language - Language to extract
|
||||
// #3 ListFile - ListFile to write the MUI path
|
||||
@@ -877,7 +879,7 @@ System,EndLocal
|
||||
// we should check if the files exist first using WimExistFile, but it slows things down too much with large lists.
|
||||
// Related........: RequireFileEx
|
||||
// ===============================================================================================================================
|
||||
[__PhoenixAPI_RequireFileEx_ProcessMUI]
|
||||
[__PhoenixAPI_RequireFileEx_Process_MUI]
|
||||
System,SetLocal
|
||||
GetParam,1,%GLOB%
|
||||
GetParam,2,%Language%
|
||||
@@ -1308,6 +1310,41 @@ While,ExistFile,#1,Begin
|
||||
|
||||
End
|
||||
|
||||
[#_PhoenixAPI_FileSearch#]
|
||||
// ===============================================================================================================================
|
||||
// Name...........: FileSearch
|
||||
// Description....: Search for a file and return it's full path if it exists. If the file cannot be found an empty string is returned.
|
||||
// Syntax.........: FileSearch,<Directory>,<File>
|
||||
// Parameters.....: #1 Directory - The directory to search recursively for the specified file.
|
||||
// #2 Filter - The name of the file including it's extension to search for. (Ex. MyProgram.exe). Wildcards are supported.
|
||||
// Return values..: Success - A pipe separated list containing the full path(s) to the file.
|
||||
// Fail (File not found) - An Empty String
|
||||
// Author.........: Homes32
|
||||
// Remarks........: This command is a work in progress and may change without notice.
|
||||
// Usage: PhoenixAPI-FileSearch.a3x <PathToSearch> <SearchFilter> <OutputFile>
|
||||
// PathToSearch - Full path to search (iterative)
|
||||
// SearchFilter - Filename or filter to search for. Wildcards are supported.
|
||||
// OutputFile - A standard .ini formatted File
|
||||
// [Results] contains key=value pairs of paths found in the format of 0-n=Path where 0 is the number of results and n is the index
|
||||
// [String] contains one key=value pair List= where the value is a | separated list of paths
|
||||
// Exit codes: 0 - Success
|
||||
// 1 - Syntax Error
|
||||
// Related........:
|
||||
// ===============================================================================================================================
|
||||
[_PhoenixAPI_FileSearch]
|
||||
System,SetLocal
|
||||
GetParam,1,%Path%
|
||||
GetParam,2,%SearchFilter%
|
||||
|
||||
// Recurse the path looking for the specified file
|
||||
ShellExecute,Hide,"%Tools%\%HostArch%\AutoIt3.exe","%Tools%\a3x\PhoenixAPI-FileSearch.a3x #$q%Path%#$q #$q%SearchFilter%#$q #$q%ProjectTemp%\PhoenixAPI-FileSearch.ini#$q"
|
||||
|
||||
// Return the result as #r
|
||||
IniRead,"%ProjectTemp%\PhoenixAPI-FileSearch.ini","String","List",%SearchResult%,"Default="
|
||||
Return,%SearchResult%
|
||||
|
||||
System,EndLocal
|
||||
|
||||
[#_PhoenixAPI_InnoCleanup#]
|
||||
// ===============================================================================================================================
|
||||
// Name...........: InnoCleanup
|
||||
|
BIN
Projects/PhoenixPE/Tools/a3x/PhoenixAPI-FileSearch.a3x
Normal file
BIN
Projects/PhoenixPE/Tools/a3x/PhoenixAPI-FileSearch.a3x
Normal file
Binary file not shown.
BIN
Projects/PhoenixPE/Tools/x64/AutoIt3.exe
Normal file
BIN
Projects/PhoenixPE/Tools/x64/AutoIt3.exe
Normal file
Binary file not shown.
BIN
Projects/PhoenixPE/Tools/x86/AutoIt3.exe
Normal file
BIN
Projects/PhoenixPE/Tools/x86/AutoIt3.exe
Normal file
Binary file not shown.
Reference in New Issue
Block a user