Added XMLRead command to PhoenixAPI (Issue #64)

- Allows reading a single value from an XML file.
This commit is contained in:
Homes32
2024-01-03 21:41:54 -06:00
parent b345148396
commit d0739c26c8

View File

@@ -32,8 +32,8 @@
Title=PhoenixPE API Title=PhoenixPE API
Author=Homes32 Author=Homes32
Description=PhoenixPE scripting support library. Description=PhoenixPE scripting support library.
Version=1.8.0.0 Version=1.9.0.0
Date=2023-09-21 Date=2024-01-02
Level=0 Level=0
Selected=None Selected=None
@@ -98,7 +98,7 @@ JSONWrite=Run,%API%,_PhoenixAPI_JSONWrite
// XML // XML
XMLAdd=Run,%API%,_PhoenixAPI_XMLAdd XMLAdd=Run,%API%,_PhoenixAPI_XMLAdd
XMLDelete=Run,%API%,_PhoenixAPI_XMLDelete XMLDelete=Run,%API%,_PhoenixAPI_XMLDelete
//XMLRead=NOT IMPLIMENTED XMLRead=Run,%API%,_PhoenixAPI_XMLRead
XMLRename=Run,%API%,_PhoenixAPI_XMLRename XMLRename=Run,%API%,_PhoenixAPI_XMLRename
XMLUpdate=Run,%API%,_PhoenixAPI_XMLUpdate XMLUpdate=Run,%API%,_PhoenixAPI_XMLUpdate
@@ -914,7 +914,8 @@ System,EndLocal
// #5 Parameters - (Optional) Parameters that will be passed to the program. // #5 Parameters - (Optional) Parameters that will be passed to the program.
// Return values..: // Return values..:
// Author.........: Homes32 // Author.........: Homes32
// Remarks........: PECMD: EXEC {[-hide] [-wait]} <ProgramExe> [Parameters] // Remarks........: RunProgram($sProgramExe, $sArgs = "", $sWorkDir = @ScriptDir, $iShowFlag = @SW_SHOWNORMAL)
// RunProgramWait($sProgramExe, $sArgs = "", $sWorkDir = @ScriptDir, $iShowFlag = @SW_SHOWNORMAL)
// Related........: // Related........:
// =============================================================================================================================== // ===============================================================================================================================
[_PhoenixAPI_AddAutoRun] [_PhoenixAPI_AddAutoRun]
@@ -1023,9 +1024,8 @@ TxtAddLine,"%TargetSystem32%\RunAfterNetwork.cmd","START #$q%Title%#$q %ExecMode
// Parameters.....: #1 RunGroup // Parameters.....: #1 RunGroup
// PreShell - Run before the shell (ie. Explorer) is loaded. // PreShell - Run before the shell (ie. Explorer) is loaded.
// PostShell - Run after the shell is loaded. // PostShell - Run after the shell is loaded.
// RunOnce - Run during startup via HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce // Network - Run during network initialization.
// AfterNetwork - Run after network connectivity has been established by PENetwork. // #2 Code - Free-form line of AutoIt3 code to be inserted. Be sure to escape quotes, etc. Use #$x to insert multiple lines in one statement.
// #2 Mode - Free-from line of code to be inserted. Be sure to escape quotes, etc. Use #$x to insert multiple lines in one statement.
// #3 Position - (Optional) Define where in the RunGroup the code will be inserted. Valid options are: // #3 Position - (Optional) Define where in the RunGroup the code will be inserted. Valid options are:
// Append - (Default) Place the code at the end of the run group. // Append - (Default) Place the code at the end of the run group.
// Prepend - Place the code at the start of the run group. // Prepend - Place the code at the start of the run group.
@@ -1053,7 +1053,7 @@ End
Else,If,%Position%,Equal,"Prepend",Begin Else,If,%Position%,Equal,"Prepend",Begin
If,%RunGroup%,Equal,"Preshell",TXTReplace,"%TargetSystem32%\PhoenixPE.au3","Func PreShellConfig()","%Code%#$x#$xFunc PreShellConfig()" If,%RunGroup%,Equal,"Preshell",TXTReplace,"%TargetSystem32%\PhoenixPE.au3","Func PreShellConfig()","%Code%#$x#$xFunc PreShellConfig()"
Else,If,%RunGroup%,Equal,"Postshell",TXTReplace,"%TargetSystem32%\PhoenixPE.au3","Func PostShellConfig()","%Code%#$x#$xFunc PostShellConfig()" Else,If,%RunGroup%,Equal,"Postshell",TXTReplace,"%TargetSystem32%\PhoenixPE.au3","Func PostShellConfig()","%Code%#$x#$xFunc PostShellConfig()"
Else,If,%RunGroup%,Equal,"NetInit",TXTReplace,"%TargetSystem32%\PhoenixPE.au3","Func InitNetwork()","%Code%#$x#$xFunc InitNetwork()" Else,If,%RunGroup%,Equal,"Network",TXTReplace,"%TargetSystem32%\PhoenixPE.au3","Func InitNetwork()","%Code%#$x#$xFunc InitNetwork()"
Else,Halt,"AddStartupConfig Syntax Error: [%RunGroup%] is not a supported Run group." Else,Halt,"AddStartupConfig Syntax Error: [%RunGroup%] is not a supported Run group."
End End
Else,Halt,"AddStartupConfig Syntax Error: [%Position%] must be either [Append] or [Prepend]." Else,Halt,"AddStartupConfig Syntax Error: [%Position%] must be either [Append] or [Prepend]."
@@ -1084,12 +1084,7 @@ System,EndLocal
// #11 Tooltip - Tooltip Text // #11 Tooltip - Tooltip Text
// Return values..: // Return values..:
// Author.........: Homes32 // Author.........: Homes32
// Remarks........: PECMD: LINK {[!] {[_]|[^]}} <ShortcutPath>, <TargetPath>, [Parameters], [IconPath[#IconIndex]], [Tooltip], [WorkDir], [HotKey] // Remarks........: MakeShortcut($sFile, $sLnk, $sWorkDir = @ScriptDir, $sArgs = "", $sDesc = "", $sIcon = "", $sHotkey = "", $iIconNumber = 0, $iState = @SW_SHOWNORMAL)
// WindowState: ! - Hide, _ - Minimize, ^ - Maximize
//
// Shortcuts.exe: <ShortcutPath> | <Title> | <TargetPath> | [IconPath,IconIndex] | [Parameters]
//
// TODO: Shortcuts.exe needs to support all AddShortcut parameters. This requires rewriting a portion of shortcuts.exe
// Related........: // Related........:
// =============================================================================================================================== // ===============================================================================================================================
[_PhoenixAPI_AddShortcut] [_PhoenixAPI_AddShortcut]
@@ -1132,7 +1127,7 @@ If,%WindowState%,Equal,"Minimized",Set,%Cmd-WindowState%,"@SW_SHOWMINNOACTIVE "
Else,If,%WindowState%,Equal,"Maximized",Set,%Cmd-WindowState%,"@SW_SHOWMAXIMIZED" Else,If,%WindowState%,Equal,"Maximized",Set,%Cmd-WindowState%,"@SW_SHOWMAXIMIZED"
Else,Set,%Cmd-WindowState%,"@SW_SHOWNORMAL" Else,Set,%Cmd-WindowState%,"@SW_SHOWNORMAL"
// Final command - MakeShortcut($sFile, $sLnk, $sWorkdir = @ScriptDir, $sArgs = "", $sDesc = "", $sIcon = "", $sHotkey = "", $iIconNumber = 0, $iState = @SW_SHOWNORMAL) // Final command
TXTReplace,"%TargetSystem32%\PhoenixPE.au3","EndFunc ;==>CreateShortcuts","MakeShortcut(#$q%ProgramExe%#$q, %Cmd-Type% & #$q%Folder%\%Title%.lnk#$q, #$q%WorkDir%#$q, #$q%Parameters%#$q, #$q%Tooltip%#$q, #$q%IconPath%#$q, #$q%HotKey%#$q, %IconIndex%, %Cmd-WindowState%)#$x#$xEndFunc ;==>CreateShortcuts" TXTReplace,"%TargetSystem32%\PhoenixPE.au3","EndFunc ;==>CreateShortcuts","MakeShortcut(#$q%ProgramExe%#$q, %Cmd-Type% & #$q%Folder%\%Title%.lnk#$q, #$q%WorkDir%#$q, #$q%Parameters%#$q, #$q%Tooltip%#$q, #$q%IconPath%#$q, #$q%HotKey%#$q, %IconIndex%, %Cmd-WindowState%)#$x#$xEndFunc ;==>CreateShortcuts"
System,EndLocal System,EndLocal
@@ -1627,7 +1622,7 @@ System,EndLocal
// Description....: Experimental wrapper for jj - Compress the JSON into the fewest characters possible by squashing newlines and spaces. // Description....: Experimental wrapper for jj - Compress the JSON into the fewest characters possible by squashing newlines and spaces.
// Syntax.........: JSONCompact,<JSONFile> // Syntax.........: JSONCompact,<JSONFile>
// Parameters.....: #1 JSONFile - Full path to the JSON filed to compact. // Parameters.....: #1 JSONFile - Full path to the JSON filed to compact.
// Return values..: #r - Returns // Return values..:
// Author.........: Homes32 // Author.........: Homes32
// Remarks........: https://github.com/tidwall/jj // Remarks........: https://github.com/tidwall/jj
// Related........: Depends on %Tools%\%HostArch%\jj.exe // Related........: Depends on %Tools%\%HostArch%\jj.exe
@@ -1650,7 +1645,7 @@ System,EndLocal
// Syntax.........: JSONDelete,<JSONFile>,<Path> // Syntax.........: JSONDelete,<JSONFile>,<Path>
// Parameters.....: #1 JSONFile - Full path to the JSON filed to edit. // Parameters.....: #1 JSONFile - Full path to the JSON filed to edit.
// #2 Path - GJSON Path notation used to locate the value to delete. // #2 Path - GJSON Path notation used to locate the value to delete.
// Return values..: #r - Returns // Return values..:
// Author.........: Homes32 // Author.........: Homes32
// Remarks........: jj.exe Homepage: https://github.com/tidwall/jj // Remarks........: jj.exe Homepage: https://github.com/tidwall/jj
// Path Syntax Help: https://github.com/tidwall/gjson/blob/master/SYNTAX.md // Path Syntax Help: https://github.com/tidwall/gjson/blob/master/SYNTAX.md
@@ -1675,7 +1670,7 @@ System,EndLocal
// Description....: Experimental wrapper for jj - Format and indent the JSON file for easy human reading. // Description....: Experimental wrapper for jj - Format and indent the JSON file for easy human reading.
// Syntax.........: JSONPretty,<JSONFile> // Syntax.........: JSONPretty,<JSONFile>
// Parameters.....: #1 JSONFile - Full path to the JSON filed to compact. // Parameters.....: #1 JSONFile - Full path to the JSON filed to compact.
// Return values..: #r - Returns // Return values..:
// Author.........: Homes32 // Author.........: Homes32
// Remarks........: https://github.com/tidwall/jj // Remarks........: https://github.com/tidwall/jj
// Related........: Depends on %Tools%\%HostArch%\jj.exe // Related........: Depends on %Tools%\%HostArch%\jj.exe
@@ -1698,7 +1693,8 @@ System,EndLocal
// Syntax.........: JSONRead,<JSONFile>,<Path> // Syntax.........: JSONRead,<JSONFile>,<Path>
// Parameters.....: #1 JSONFile - Full path to the JSON filed to read. // Parameters.....: #1 JSONFile - Full path to the JSON filed to read.
// #2 Path - GJSON Path notation used to locate the value to read. // #2 Path - GJSON Path notation used to locate the value to read.
// Return values..: #r - Returns the value of <Path> // Return values..: #r - Success - Returns the value of <Path>
// Failure - Returns ""
// Author.........: Homes32 // Author.........: Homes32
// Remarks........: jj.exe Homepage: https://github.com/tidwall/jj // Remarks........: jj.exe Homepage: https://github.com/tidwall/jj
// Path Syntax Help: https://github.com/tidwall/gjson/blob/master/SYNTAX.md // Path Syntax Help: https://github.com/tidwall/gjson/blob/master/SYNTAX.md
@@ -1739,7 +1735,7 @@ System,EndLocal
// Parameters.....: #1 JSONFile - Full path to the JSON filed to edit. // Parameters.....: #1 JSONFile - Full path to the JSON filed to edit.
// #2 Path - GJSON Path notation used to locate the value to write. // #2 Path - GJSON Path notation used to locate the value to write.
// #3 Value - The value to write. (Can be empty) // #3 Value - The value to write. (Can be empty)
// Return values..: #r - Returns // Return values..:
// Author.........: Homes32 // Author.........: Homes32
// Remarks........: jj.exe Homepage: https://github.com/tidwall/jj // Remarks........: jj.exe Homepage: https://github.com/tidwall/jj
// Path Syntax Help: https://github.com/tidwall/gjson/blob/master/SYNTAX.md // Path Syntax Help: https://github.com/tidwall/gjson/blob/master/SYNTAX.md
@@ -1773,10 +1769,9 @@ System,EndLocal
// #4 Type - XPath type [elem|text|attr] // #4 Type - XPath type [elem|text|attr]
// #5 Name - Value Name // #5 Name - Value Name
// #6 Value - (Optional) Value // #6 Value - (Optional) Value
// Return values..: #r - Returns // Return values..:
// Author.........: Homes32 // Author.........: Homes32
// Remarks........: // Remarks........: http://xmlstar.sourceforge.net/doc/UG/xmlstarlet-ug.pdf
// http://xmlstar.sourceforge.net/doc/UG/xmlstarlet-ug.pdf
// Related........: // Related........:
// =============================================================================================================================== // ===============================================================================================================================
[_PhoenixAPI_XMLAdd] [_PhoenixAPI_XMLAdd]
@@ -1794,9 +1789,6 @@ If,%XPath%,Equal,"",Halt,"XMLAdd Syntax Error: You must specify an XPath."
If,%Type%,Equal,"",Halt,"XMLAdd Syntax Error: You must specify a type [elem|text|attr]." If,%Type%,Equal,"",Halt,"XMLAdd Syntax Error: You must specify a type [elem|text|attr]."
If,%Name%,Equal,"",Halt,"XMLAdd Syntax Error: You must specify a name." If,%Name%,Equal,"",Halt,"XMLAdd Syntax Error: You must specify a name."
//ShellExecute,Hide,"%Tools%\x86\xml.exe","select --text --template --value-of #$q%XPath%/@%Name%#$q #$q%XMLFile%#$q"
//If,Not,#r,Equal,0,Halt,"XMLAdd ERROR: Failed to query [%XPath%/@%Name%] from [%XMLFile%]."
If,%Operation%,Equal,"Insert",Begin If,%Operation%,Equal,"Insert",Begin
ShellExecute,Hide,"%Tools%\x86\xml.exe","edit --inplace --insert #$q%XPath%#$q --type #$q%Type%#$q --name #$q%Name%#$q --value #$q%Value%#$q #$q%XMLFile%#$q" ShellExecute,Hide,"%Tools%\x86\xml.exe","edit --inplace --insert #$q%XPath%#$q --type #$q%Type%#$q --name #$q%Name%#$q --value #$q%Value%#$q #$q%XMLFile%#$q"
If,Not,#r,Equal,0,Halt,"XMLAdd ERROR: Failed to insert value [%XPath%/%Name%: %Value%] to [%XMLFile%]." If,Not,#r,Equal,0,Halt,"XMLAdd ERROR: Failed to insert value [%XPath%/%Name%: %Value%] to [%XMLFile%]."
@@ -1820,7 +1812,7 @@ System,EndLocal
// Syntax.........: XMLDelete,<XMLFile>,<XPath> // Syntax.........: XMLDelete,<XMLFile>,<XPath>
// Parameters.....: #1 XMLFile - Full path to the .xml filed to edit. // Parameters.....: #1 XMLFile - Full path to the .xml filed to edit.
// #2 XPath - XPath (XML Path Language) query used to locate the Attribute/Element to delete. // #2 XPath - XPath (XML Path Language) query used to locate the Attribute/Element to delete.
// Return values..: #r - Returns // Return values..:
// Author.........: Homes32 // Author.........: Homes32
// Remarks........: http://xmlstar.sourceforge.net/doc/UG/xmlstarlet-ug.pdf // Remarks........: http://xmlstar.sourceforge.net/doc/UG/xmlstarlet-ug.pdf
// Related........: // Related........:
@@ -1833,14 +1825,60 @@ GetParam,2,%XPath%
If,Not,ExistFile,%XMLFile%,Halt,"XMLDelete Syntax Error: The file [%XMLFile%] does not exist." If,Not,ExistFile,%XMLFile%,Halt,"XMLDelete Syntax Error: The file [%XMLFile%] does not exist."
If,%XPath%,Equal,"",Halt,"XMLDelete Syntax Error: You must specify an XPath." If,%XPath%,Equal,"",Halt,"XMLDelete Syntax Error: You must specify an XPath."
//ShellExecute,Hide,"%Tools%\x86\xml.exe","select --text --template --value-of #$q%XPath%#$q #$q%XMLFile%#$q"
//If,Not,#r,Equal,0,Halt,"XMLDelete ERROR: Failed to query [%XPath%] from [%XMLFile%]."
ShellExecute,Hide,"%Tools%\x86\xml.exe","edit --inplace --delete #$q%XPath%#$q #$q%XMLFile%#$q" ShellExecute,Hide,"%Tools%\x86\xml.exe","edit --inplace --delete #$q%XPath%#$q #$q%XMLFile%#$q"
If,Not,#r,Equal,0,Halt,"XMLDelete ERROR: Failed to delete [%XPath%] from [%XMLFile%]." If,Not,#r,Equal,0,Halt,"XMLDelete ERROR: Failed to delete [%XPath%] from [%XMLFile%]."
System,EndLocal System,EndLocal
[#_PhoenixAPI_XMLRead#]
// ===============================================================================================================================
// Name...........: XMLRead
// Description....: Experimental wrapper for XmlStarlet - Read a value from an XML file.
// Syntax.........: XMLRename,<XMLFile>,<XPath>
// Parameters.....: #1 XMLFile - Full path to the .xml filed to edit.
// #2 XPath - XPath (XML Path Language) query used to locate the value to read.
// #3 NOERR - Don't Halt on errors. (Use if you intend to handle errors yourself).
// eg. If check #r to see if XMLRead fails and then call XMLAdd
// Return values..: #r - Success - Returns the value of <XPath>
// Failure - Returns ""
// Author.........: Homes32
// Remarks........: The current implementation of this function only returns a single value.
// http://xmlstar.sourceforge.net/doc/UG/xmlstarlet-ug.pdf
// Related........:
// ===============================================================================================================================
[_PhoenixAPI_XMLRead]
System,SetLocal
GetParam,1,%XMLFile%
GetParam,2,%XPath%
GetParam,3,%Arg3%
If,Not,ExistFile,%XMLFile%,Halt,"XMLRead Syntax Error: The file [%XMLFile%] does not exist."
If,%Path%,Equal,"",Halt,"XMLRead Syntax Error: You must specify an XPath."
If,%Arg3%,Equal,"NOERR",Set,%NOERR%,"True"
FileDeleteEx,"%ProjectTemp%\PhoenixAPI-XMLRead.txt"
FileDeleteEx,"%ProjectTemp%\PhoenixAPI-XMLRead.ini"
ShellExecute,Hide,"cmd.exe","/c #$q#$q%Tools%\x86\xml.exe#$q select --text --template --value-of #$q%XPath%#$q #$q%XMLFile%#$q > #$q%ProjectTemp%\PhoenixAPI-XMLRead.txt#$q#$q"
If,Not,#r,Equal,0,Begin
If,%NOERR%,Equal,"True",Return,""
Else,Halt,"XMLRead ERROR: Failed to read [%XMLFile%]."
End
ShellExecute,Hide,"cmd.exe","/c for /f #$qtokens=*#$q %a in (PhoenixAPI-XMLRead.txt) do (echo Value=%a) > #$q%ProjectTemp%\PhoenixAPI-XMLRead.ini#$q",%ProjectTemp%
If,ExistFile,"%ProjectTemp%\PhoenixAPI-XMLRead.ini",Begin
// Value was found in XML file
TXTAddLine,"%ProjectTemp%\PhoenixAPI-XMLRead.ini","[Read]",PREPEND
IniRead,"%ProjectTemp%\PhoenixAPI-XMLRead.ini","Read","Value",#r
End
Else,Begin
// Value was not found (we should never get here)
Return,""
End
System,EndLocal
[#_PhoenixAPI_XMLRename#] [#_PhoenixAPI_XMLRename#]
// =============================================================================================================================== // ===============================================================================================================================
// Name...........: XMLRename // Name...........: XMLRename
@@ -1849,7 +1887,7 @@ System,EndLocal
// Parameters.....: #1 XMLFile - Full path to the .xml filed to edit. // Parameters.....: #1 XMLFile - Full path to the .xml filed to edit.
// #2 XPath - XPath (XML Path Language) query used to locate the Attribute/Element to rename. // #2 XPath - XPath (XML Path Language) query used to locate the Attribute/Element to rename.
// #3 Value - New Value // #3 Value - New Value
// Return values..: #r - Returns // Return values..:
// Author.........: Homes32 // Author.........: Homes32
// Remarks........: The XPath must exist in order for the value to be Renamed. // Remarks........: The XPath must exist in order for the value to be Renamed.
// http://xmlstar.sourceforge.net/doc/UG/xmlstarlet-ug.pdf // http://xmlstar.sourceforge.net/doc/UG/xmlstarlet-ug.pdf
@@ -1865,9 +1903,6 @@ If,Not,ExistFile,%XMLFile%,Halt,"XMLRename Syntax Error: The file [%XMLFile%] do
If,%XPath%,Equal,"",Halt,"XMLRename Syntax Error: You must specify an XPath." If,%XPath%,Equal,"",Halt,"XMLRename Syntax Error: You must specify an XPath."
If,%Value%,Equal,"",Halt,"XMLRename Syntax Error: You must specify a value." If,%Value%,Equal,"",Halt,"XMLRename Syntax Error: You must specify a value."
//ShellExecute,Hide,"%Tools%\x86\xml.exe","select --text --template --value-of #$q%XPath%#$q #$q%XMLFile%#$q"
//If,Not,#r,Equal,0,Halt,"XMLRename ERROR: Failed to query [%XPath%] from [%XMLFile%]."
ShellExecute,Hide,"%Tools%\x86\xml.exe","edit --inplace --rename #$q%XPath%#$q --value #$q%Value%#$q #$q%XMLFile%#$q" ShellExecute,Hide,"%Tools%\x86\xml.exe","edit --inplace --rename #$q%XPath%#$q --value #$q%Value%#$q #$q%XMLFile%#$q"
If,Not,#r,Equal,0,Halt,"XMLRename ERROR: Failed to write value [%XPath%: %Value%] to [%XMLFile%]." If,Not,#r,Equal,0,Halt,"XMLRename ERROR: Failed to write value [%XPath%: %Value%] to [%XMLFile%]."
@@ -1882,6 +1917,7 @@ System,EndLocal
// #2 XPath - XPath (XML Path Language) query used to locate the Attribute/Element to update. // #2 XPath - XPath (XML Path Language) query used to locate the Attribute/Element to update.
// #3 Value - New Value // #3 Value - New Value
// #4 NOERR - Don't Halt on errors. (Use if you intend to handle errors yourself). // #4 NOERR - Don't Halt on errors. (Use if you intend to handle errors yourself).
// eg. If check #r to see if XMLUpdate fails and then call XMLAdd
// Return values..: #r - Returns: 0 - Success // Return values..: #r - Returns: 0 - Success
// 1 - Failure // 1 - Failure
// 2 - Invalid Arguments // 2 - Invalid Arguments
@@ -1899,20 +1935,27 @@ System,SetLocal
GetParam,1,%XMLFile% GetParam,1,%XMLFile%
GetParam,2,%XPath% GetParam,2,%XPath%
GetParam,3,%Value% GetParam,3,%Value%
GetParam,4,%NOERR% GetParam,4,%Arg3%
If,Not,ExistFile,%XMLFile%,Halt,"XMLUpdate Syntax Error: The file [%XMLFile%] does not exist." If,Not,ExistFile,%XMLFile%,Halt,"XMLUpdate Syntax Error: The file [%XMLFile%] does not exist."
If,%XPath%,Equal,"",Halt,"XMLUpdate Syntax Error: You must specify an XPath." If,%XPath%,Equal,"",Halt,"XMLUpdate Syntax Error: You must specify an XPath."
If,%Value%,Equal,"",Halt,"XMLUpdate Syntax Error: You must specify a value." If,%Value%,Equal,"",Halt,"XMLUpdate Syntax Error: You must specify a value."
If,%Arg3%,Equal,"NOERR",Set,%NOERR%,"True"
ShellExecute,Hide,"%Tools%\x86\xml.exe","select --text --template --value-of #$q%XPath%#$q #$q%XMLFile%#$q" ShellExecute,Hide,"%Tools%\x86\xml.exe","select --text --template --value-of #$q%XPath%#$q #$q%XMLFile%#$q"
If,Not,#r,Equal,0,Begin If,Not,#r,Equal,0,Begin
If,Not,%NOERR%,Equal,"NOERR",Halt,"XMLUpdate ERROR: Failed to query [%XPath%] from [%XMLFile%]. The XPath must exist in order for the value to be updated." If,%NOERR%,Equal,"False",Halt,"XMLUpdate ERROR: Failed to query [%XPath%] from [%XMLFile%]. The XPath must exist in order for the value to be updated."
Return,-99999999 Return,-99999999
End End
Else,Begin Else,Begin
ShellExecute,Hide,"%Tools%\x86\xml.exe","edit --inplace --update #$q%XPath%#$q --value #$q%Value%#$q #$q%XMLFile%#$q" ShellExecute,Hide,"%Tools%\x86\xml.exe","edit --inplace --update #$q%XPath%#$q --value #$q%Value%#$q #$q%XMLFile%#$q"
If,Not,#r,Equal,0,Halt,"XMLUpdate ERROR: Failed to write value [%XPath%: %Value%] to [%XMLFile%]." If,#r,Equal,0,Return,0
Else,Begin
// There was a problem writing the XML file
If,%NOERR%,Equal,True,Return,5
Else,Halt,"XMLUpdate ERROR: Failed to write value [%XPath%: %Value%] to [%XMLFile%]."
End
End End
System,EndLocal System,EndLocal