On Windows server 2016 or 2019, some characters are removed in PATH environment variable during uninstallation of ITCM Agents.
This problem is not seen in Windows 10, Windows 11 or Windows Server 2022
Client Automation 14.5
Make sure that Basic Agent is uninstalled at the end after all others plugins
OR (if Basic Agent is not present or was already removed) :
The workaround for both Windows 2016 and Windows 2019 :
1- Execute this powershell command before uninstallation of agents to add a temporary path "c:\testbegin d d d d d d testend;" at beginning of PATH variable :
$tmppath="c:\testbegin d d d d d d testend;"+[System.Environment]::GetEnvironmentVariable("Path","Machine")
[System.Environment]::SetEnvironmentVariable("Path",$tmppath,"Machine")
2- Execute this at the end of script to remove the temp path "c:\testbegin d d d d d d testend;"
$tmppath=[System.Environment]::GetEnvironmentVariable("Path","Machine") -replace 'c:\\testbegin.*testend;',''
[System.Environment]::SetEnvironmentVariable("Path",$tmppath,"Machine")
A correction in CAWIN cleanup procedure will be added in future release of Client Automation product (in MSI files located in iso).