xar*_*rzu 54 .net installation command-line windows-installer msiexec
msiexec
是安装MSI程序的命令提示符软件.但我发现只需在命令行输入MSI文件的名称,就可以从命令行安装MSI文件.
但是为了卸载MSI文件,你似乎必须调用该msiexec
程序并给它一个/x
或/uninstall
.
如何在不使用msiexec
例程的情况下从命令行卸载MSI ?
Ste*_*mul 148
There are many ways to uninstall an MSI package. This is intended as a "reference".
In summary you can uninstall via: msiexec.exe, ARP, WMI, PowerShell, Deployment Systems such as SCCM, VBScript/COM Automation, DTF, or via hidden Windows cache folder, and a few other options presented below.
The first few paragraphs provide important MSI tidbits, then there are 14 sections with different ways to uninstall an MSI file. Puh.
段1,2和3是正常卸载方法(因此推荐).我个人使用第3节中的选项3或5(两个选项都带有日志记录,但选项5也以静默方式运行).如果你很忙,可以跳过所有的唠叨,然后选择其中一个 - 它将完成工作.
如果您在完全卸载时遇到问题,并且正在寻找已弃用的替代方案MSIZAP.EXE 和/或Windows Installer CleanUp Utility(MSICUU2.exe),您可以尝试从Microsoft(或国际页面)的新FixIt工具.可能显然也适用于其他安装问题.
如果您认为MSI和Windows Installer比它的价值更麻烦,您可能想了解使用MSI文件的公司优势.
Installscript MSI设置通常包含在setup.exe文件中.要阅读有关用于卸载此类设置的参数的更多信息,请参阅以下链接:setup.exe pdf参考表,Setup.exe和Update.exe命令行参数.
某些MSI文件通过Burn(WiX Toolkit)或InstallShield Suite项目等机制作为bundle的一部分安装.这可以使卸载与下面的内容略有不同.以下是InstallShield Suite项目的示例.
请注意,以静默方式或交互方式运行卸载会导致不同的结果(!).有关为什么会出现这种情况的相当冗长的描述,请阅读以下文章:从控制面板卸载与从.msi删除不同
If you are unexpectedly asked for the original installation media when trying to uninstall, please read this answer: Why does MSI require the original .msi file to proceed with an uninstall? and perhaps also section 12 below for some important technical details.
If you got CCleaner or similar cleanup tools installed, perhaps jump to section 11.
If uninstall is failing entirely (not possible to run), see sections 12 & 13 below for a potential way to "undo" the installation using system restore and/or cleanup tools.
For all the command lines below you can add Personally I use option 3 or 5 from section 3
to make the uninstall run in silent mode. This is how an uninstall runs when triggered from the add/remove applet.
Option 1: Basic interactive uninstall (access to original MSI file):
msiexec.exe /x "c:\filename.msi"
Run Code Online (Sandbox Code Playgroud)选项2:通过产品GUID进行基本交互式卸载(无法访问原始MSI文件 - 以下是如何查找产品GUID - 相同链接,如下所示):
msiexec.exe /x {11111111-1111-1111-1111-11111111111X}
Run Code Online (Sandbox Code Playgroud)选项3:使用详细日志文件进行交互式卸载:
msiexec.exe /x "c:\filename.msi" /L*V "C:\msilog.log"
msiexec.exe /x {11111111-1111-1111-1111-11111111111X} /L*V "C:\msilog.log"
Run Code Online (Sandbox Code Playgroud)选项4:使用刷新的详细日志文件进行交互式卸载(详细,刷新到日志选项 - 连续写入日志,可能非常慢):
msiexec.exe /x "c:\filename.msi" /L*V! "C:\msilog.log"
msiexec.exe /x {11111111-1111-1111-1111-11111111111X} /L*V! "C:\msilog.log"
Run Code Online (Sandbox Code Playgroud)
flush to log选项使卸载变慢,因为日志文件是连续写入而不是批量写入.这可确保在安装程序崩溃时不会丢失日志缓冲区.
In other words, enable this option if your setup is crashing and there is no helpful information in your verbose log file. Remove the exclamation mark to turn off the flush to log option and the uninstall will be much quicker. You still get verbose logging, but as stated some log buffer could be lost.
Option 5 (recommended): Silent uninstall with verbose log file - suppress reboots (no flush to log - see previous option for what this means):
msiexec.exe /x "c:\filename.msi" /QN /L*V "C:\msilog.log" REBOOT=R
msiexec.exe /x {11111111-1111-1111-1111-11111111111X} /QN /L*V "C:\msilog.log" REBOOT=R
Run Code Online (Sandbox Code Playgroud)
Quick Parameter Explanation (since I recommend this option):
/X = run uninstall sequence
/QN = run completely silently
/L*V "C:\msilog.log"= verbose logging at path specified
{11111111-1111-1111-1111-11111111111X} = product guid of app to uninstall
REBOOT=R = prevent unexpected reboot of computer
Run Code Online (Sandbox Code Playgroud)
Again, how to find the product guid: How can I find the product GUID of an installed MSI setup? (for uninstall if you don't have the original MSI to specify in the uninstall command).
Top tip: If you create a log file for your uninstall, you can locate problems in the log by searching for "value 3". This is particularly useful for verbose files, because they are so, well, verbose :-).
How to find the product GUID for an installed MSI?
More information on logging from installsite.org: How do I create a log file of my installation? - great overview of different options and also specifics of InstallShield logging.
get-wmiobject Win32_Product | Format-Table Name, LocalPackage -AutoSize
Run Code Online (Sandbox Code Playgroud)
Entry added by Even Mien:
$app = Get-WmiObject -Class Win32_Product -Filter "Name = 'YOUR_APP'"
$app.Uninstall()
Run Code Online (Sandbox Code Playgroud)This approach will work, but accessing the WMI class Win32_Product will trigger a software consistency check which is very slow and in special circumstances it can cause an MSI self-repair to be triggered. See this article: Powershell Uninstall Script - Have a real headache
using Microsoft.Deployment.WindowsInstaller;
public static void Uninstall( string productCode)
{
Installer.ConfigureProduct(productCode, 0, InstallState.Absent, "REBOOT=\"R\"");
}
Run Code Online (Sandbox Code Playgroud)
The following source adapted from MSI expert Christopher Painter using VBScript:
Set installer = CreateObject("WindowsInstaller.Installer")
installer.InstallProduct "product.msi", "REMOVE=ALL REBOOT=ReallySuppress"
Set installer = Nothing
Run Code Online (Sandbox Code Playgroud)Here is another VBScript for uninstalling by GUID from Symantec: http://www.symantec.com/connect/downloads/uninstall-application-using-guid-registry
Using the original MSI
Using the old ARP Applet OR new Windows 8/10 Settings Interface
Rog*_*mbe 48
简短的回答:你做不到.使用MSIEXEC/x
答案很简单:当您在命令行直接运行MSI文件时,所发生的一切就是它为您运行MSIEXEC.此关联存储在注册表中.您可以通过(在Windows资源管理器中)查看工具/文件夹选项/文件类型的关联列表.
例如,您可以从命令行运行.DOC文件,WordPad或WinWord将为您打开它.
如果您查看下面的注册表HKEY_CLASSES_ROOT\.msi
,您将看到.MSI文件与ProgID"Msi.Package"相关联.如果查看HKEY_CLASSES_ROOT\Msi.Package\shell\Open\command
,您将看到Windows"运行".MSI文件时实际使用的命令行.
小智 31
还要记住,可以使用WMIC命令启动卸载:
wmic product get name
- >这将列出所有已安装应用的名称
wmic product where name='myappsname' call uninstall
- >这将卸载应用程序.
归档时间: |
|
查看次数: |
248747 次 |
最近记录: |