Forum Discussion
Uninstall user setup Visual Studio Code
- Oct 17, 2022
Rudy_Ooms_MVP I saved my script as Uninstall.ps1 and added it to my VSCodeUserSetup-x64-1.65.2.intunewin file and uploaded it. I then changed the Uninstall command to PowerShell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File Uninstall.ps1. It doesn’t work on my own machine, but on three others. So that’s fine, probably something weird with my computer.
Thank you very much Rudy for your help! 😀
Lookin at the silenintall hq they are also mentioning the %localappdata%
https://silentinstallhq.com/visual-studio-code-silent-install-how-to-guide/
"%LocalAppData%\Programs\Microsoft VS Code\unins000.exe" /VERYSILENT /NORESTART
But that could be indeed going wrong so why not add an uninstall script instead of adding an uninstall command?
This script will fetch the user who is running the explorer process, adds it to the path in which the uninstall.exe should exists and add its as a parameter.
$username = (get-process -name "explorer" -includeusername).username
$username = ($username -split '\\')[1]
$fileexe = 'c:\users\' + $username + '\AppData\Local\Programs\Microsoft VS Code\unins000.exe'
$arguments = '/VERYSILENT /NORESTART /MERGETASKS=!runcode /log="c:\programdata\VSCodeUninstall.log"'
$uninstall = (start-process -filepath $fileexe -argumentlist $arguments -wait -passthru).exitcode
if ($uninstall -eq '0')
{
write-host "success"
exit 0
}
else
{
write-host "fail"
exit 1
}
- Bjrn1765Sep 26, 2022Copper Contributor
Rudy_Ooms_MVP Thanks for your input Rudy! Do you use Intune yourself? If you want to be able to uninstall with a script, do you have to copy it into the file system in connection with the installation or is it included in the .intunewin package? It sounds complicated but I can try. The funny thing is, if I run "%LocalAppData%\Programs\Microsoft VS Code\unins000.exe" /SILENT /NOCANCEL manually, there is no problem.
- Sep 26, 2022Hi...
Do I use Intune myself :P... it depends.... https://callcloud.nl
When you are packaging the msi app as a win32app you are probably using the intunewinutill tool to do so.. it sort of a zip file with the powershell install and uninstall command or in this case script in it....
Deploying apps with Intune could just act a bit different then you would expect... and calling upon the localappdata could give you an issue...- Bjrn1765Sep 26, 2022Copper Contributor
Rudy_Ooms_MVP I tried to uninstall with your PS-script via Intune and got a new error Uninstall Failed:
0x80070001 and VS Code remains installed. If I run the script manually, as admin, it works.