I am working on a method of reading UninstallStrings for software from the registry. And then I'm trying to execute those strings to uninstall the software.
When I print out the variables that hold the string info, it prints the whole string (with the arguments) correctly, but I am unable to run those strings. There are multiple parts to this issue.
Some install strings are formatted like so
c:\file path\blah\app.exe /uninstall
"c:\file path\blah\app.exe" /uninstall
c:\file path\blah\app.exe --uninstall
'c:\file path\blah\app.exe' /uninstall
What I'm trying to do is figure out the best way to be able to run the uninstaller in a "universal" way. Is there a way to do this effectively?
I tried executing the strings 2 different ways.
& $uninstaller
and
Start-Process -FilePath cmd.exe -ArgumentList '/c', $uninstaller -Wait
Neither of them seem to work. No errors, but they don't seem to run because when I check the app it's still installed.
And I tried splitting the text a few ways.
$Uninstaller.split("/")[0]
$Uninstaller.split("/",2)[1]
$($Uninstaller) | Invoke-Expression
$Uninstaller.Substring(0,$Uninstaller.lastIndexOf('.exe '))
$Uninstaller.split('^(*?\.exe) *')
Thanks in advance!