Error 60002 using UninstallString

Hi community,

I have trouble figuring out where I’m wrong. Error 60002 appears when i’m trying to uninstall something using the UninstallString value from the Uninstall registry key but works just fine when i’m writing the path by myself. Just to understand better, I’m trying to run this piece of code:

$maxonpathkey = (Get-Item "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Maxon Cinema 4D R*")
    $maxonpath = (Get-RegistryKey -key $maxonpathkey -Value 'UninstallString')

		Write-Log $maxonpath // this is to understand if the value is saved and it is .
		Execute-Process -Path "$maxonpath" -Arguments "--mode unattended --debugtrace $configMSILogDir\Maxon_Cinema_Uninstall.log"

Also for the Path argument I tried with quotes and without and with ’ and nothing worked, but it worked when I changed the variable $maxonpath with the actual path like this :

Execute-Process -Path "C:\Program Files\Maxon Cinema 4D R25\uninstall.exe" -Arguments "--mode unattended --debugtrace $configMSILogDir\Maxon_Cinema_Uninstall.log"

And i used this line Write-Log $maxonpath to se if the correct value is saved in the variable and it is…

Error code from the log:

"C:\Program Files\Maxon Cinema 4D R25\uninstall.exe"]LOG]!><time="14:09:42.394120" date="12-21-2021" component="Deploy" context="NT AUTHORITY\SYSTEM" type="1" thread="10260" file="Deploy.ps1">
<![LOG[[Uninstallation] :: Function failed, setting exit code to [60002]. 
Error Record:
-------------At C:\Program Files (x86)\PSAppDeployToolkit_v3.8.4\AppDeployToolkitMain.ps1:3090 char:35
+ ... ifiedPath = Get-Command -Name $Path -CommandType 'Application' -Total ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]LOG]!><time="14:09:43.159120" date="12-21-2021" component="Execute-Process" context="NT AUTHORITY\SYSTEM" type="3" thread="10260" file="Deploy.ps1">
<![LOG[[Uninstallation] :: UNINSTALLATION phase failed Function failed, setting exit code to [60002]. 
Error Record:
-------------At C:\Program Files (x86)\PSAppDeployToolkit_v3.8.4\AppDeployToolkitMain.ps1:3090 char:35
+ ... ifiedPath = Get-Command -Name $Path -CommandType 'Application' -Total ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 (at Execute-Process<Process>, C:\Program Files (x86)\PSAppDeployToolkit_v3.8.4\AppDeployToolkitMain.ps1: line 3331
at <ScriptBlock>, C:\Users\User\Desktop\ADOBE_CREATIVECLOUD_5.6.0.788_WIN10_MUI_R01\Files\Deploy.ps1: line 234)]LOG]!><time="14:09:43.191120" date="12-21-2021" component="Deploy" context="NT AUTHORITY\SYSTEM" type="1" thread="10260" file="Deploy.ps1">
<![LOG[[Uninstallation] :: The installation progress dialog does not exist. Waiting up to 5 seconds...]LOG]!><time="14:09:43.222120" date="12-21-2021" component="Close-InstallationProgress" context="NT AUTHORITY\SYSTEM" type="1" thread="10260" file="Deploy.ps1">

1. In your first block of code you hardcode the registry path to retrieve the file path of the uninstall.EXE.

I would use PSADT’s Get-InstalledApplication instead

$MaxonUninstallARR = Get-InstalledApplication -Name 'maxon'

Also, Don’t assume you will always get information from the registry. Add code to handle empty/invalid paths

2. Write-log blows up on empty message strings
To prevent this, I add square brackets.

Write-Log "[$maxonpath]" #this is to understand if the value is saved and it is .

3. I suspect –debugtrace needs quotes
Try this:

Execute-Process -Path "C:\Program Files\Maxon Cinema 4D 
R25\uninstall.exe" -Arguments "--mode unattended --debugtrace `"
$configMSILogDir\Maxon_Cinema_Uninstall.log`"
1 Like

Thank you for the reply.
I tired using the the Get-InstalledApplication fuction and use the UninstallString from there + quotes on debugtrace and I’m getting the same error.

Execute-Process -Path "C:\Program Files\Maxon Cinema 4D 
R25\uninstall.exe" -Arguments "--mode unattended --debugtrace `"
$configMSILogDir\Maxon_Cinema_Uninstall.log`"
```  this works, but I cannot assume that the application is installed in "C:\Program Files" because the install directory can be somewhere else and this is why i need the UninstallString.

And for second topic, i'm using one if to check if the value is not null or empty, but deleted from here not to overload the code.

I had to trim the quotes from UninstallString and worked that way .

1 Like