I install an MSI file as part of my Inno Setup install script. Is there a way to also uninstall it as part of the uninstall process for my program?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The easiest way is to learn what is the GUID of that MSI package,
http://msdn.microsoft.com/en-us/library/aa370568(v=vs.85).aspx
as after installation, it will be registered under 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
(or its WOW64 one).
Once you know the GUID, it can be uninstalled by calling
MsiExec.exe /X{A879B90E-B62C-4DA4-9C3F-79A1A6CFAAF9}
Here {A879B90E-B62C-4DA4-9C3F-79A1A6CFAAF9} is an example for "Microsoft ASP.NET Web Pages - Visual Studio 2010 Tools".
回答2:
There are a lot variants to do it. With batch:
@echo off
setlocal
set "key=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
set raw=%key%\%%i
for /f "tokens=7 delims=\" %%i in ('reg query %key%') do (
if "%%i"=="Microsoft .NET Framework 3.5 SP1" (
for /f "skip=4 tokens=2,*" %%j in ('reg query "%raw%" /v UninstallString') do (
rem This command iniatlize uninstallation of .NET Framework
start /wait "%%k"
)
)
)
endlocal
exit /b
With wmic:
wmic Product where Name="Microsoft .NET Framework 3.5 SP1" call Uninstall
And more.
P.S>"Microsoft .NET Framework 3.5 SP1" is here for just an example.