need to read an XML file and make an IF decision
in a deployment package, trying to figure out a way to check the contents of a specific .xml file on the hard drive of the target PC and IF a certain string matches then abort the install ELSE proceed to delete/re-install the application, something like this batch file, but not sure best way to read xml into memory to parse it and make a decision on it:
IF EXIST "c:\dassaultsystemes\C214"
somehow read "c:\dassaultsystemes\C214\sftmgt\install.xml" file into memory
(
IF install string matches "V6R2103xE.HF9"
Exit 2
write-output "C214 already installed successfully, exiting"
ELSE
ren "c:\dassaultsystemes\C214" "c:\dassaultsystemes\C214_OLD"
timeout /t 10 /nobreak
rmdir "c:\dassaultsystemes\C214_OLD"
Exit 0
write-output "bad C214 install removed, proceeding with new install"
)
ELSE
Exit 0
write-output "proceeding with initial install"
Comments
I recommend using PowerShell, it can read XML files.
It would look something like this:
thx, i'll try that but did get this working as well:
{
$result = Select-String -path "C:\DassaultSystemes\C214\SftMgt\Install.xml" -pattern "V6R2013xE.HF9" -SimpleMatch
if ( $result.count -gt 0 )
{
Write-Output "C214 already installed successfully, exiting install package"
exit (2)
}