# P4V custom tools file path [string]$customtools = $env:USERPROFILE + "\.p4qt\customtools.xml" Write-Host "" Write-Host "Updating $customtools..." # create a document if it does not exist if (![System.IO.File]::Exists($customtools)) { $xml = [xml]' ' $xml.Save($customtools) } # get the submit tool path and entry [string]$path = Join-Path ($pwd).path "\Windows\Engine\Binaries\Win64\SubmitTool.bat" [string]$entry = "SubmitTool" [string]$p4vidfile = Join-Path ($pwd).path "P4VId.txt" if ([System.IO.File]::Exists($p4vidfile)) { $entry = [System.IO.File]::ReadAllText($p4vidfile) } Write-Host "Registering $path with P4V as $entry" # load the xml file [xml]$xml = (Get-Content $customtools) # remove existing node(s) foreach($childnode in $xml.CustomToolDefList.SelectNodes("descendant::CustomToolDef[Definition/Name='$entry']")) { $xml.CustomToolDefList.RemoveChild($childnode) | Out-Null } # create a new node [xml]$node = @" $entry $path -n --args -server `$p -user `$u -client `$c -root-dir \"`$r\" -cl %p true true "@ # import the new node and save the XML File $xml.CustomToolDefList.AppendChild($xml.ImportNode($node.CustomToolDef, $true)) | Out-Null $xml.Save($customtools)