Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

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"


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"


Exit 0
write-output "proceeding with initial install"




Date Votes
  • I recommend using PowerShell, it can read XML files.

    It would look something like this:

    [XML]$C214 = Get-Content "c:\dassaultsystemes\C214"
    if ($C214.install_string -eq "V6R2103xE.HF9") {
    Write-Output "C214 already installed successfully, exiting"
  • 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)