在我的电脑上静默卸载和安装应用程序 [英] Uninstall and Install App on my Computer silently
问题描述
我正在寻找一个脚本或一些 cmd 命令来从我的计算机上卸载任何应用程序.我正在使用 Windows 操作系统.作为一名自动化分析师,每当有新版本时,我必须不断地为不同的产品运行自动化测试.所以每次我必须卸载和安装构建时都需要时间.
我确实尝试了以下命令:
wmic product where name="product name" 调用卸载
显然它确实有效,但它没有从控制面板中删除该应用程序,而且当我再次尝试安装时,它显示安装菜单说需要卸载.但是,应用程序的数据已从安装目录中删除.
No Silver Bullet
在自动安装或卸载方面没有灵丹妙药 - 但有一个快速技巧,在常规卸载"部分中进行了描述.>
有许多不同风格的安装程序类型——而且这个列表还在不断增加.正如您将完全意识到的那样,自动化它们有点像黑色艺术.不是火箭科学,而是当事情不能可靠地工作并且没有始终有效的合适补救措施时乏味和令人厌烦.
我之前就这些问题写过很多篇文章,并且对内容进行了大量交叉链接.它很乱,但如果您点击下面的链接和链接页面,您应该能够找到许多不同 setup.exe 和安装程序类型所需的信息.
一般卸载
在进入下面的特殊列表之前,不同类型的安装程序/卸载程序以及如何处理它们的命令行参数.我想补充一点,您可以在这些注册位置中找到系统上安装的大多数产品的列表:
HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstall
(64 位)HKLMSOFTWAREWOW6432NodeMicrosoftWindowsCurrentVersionUninstall
(32 位)HKCUSoftwareMicrosoftWindowsCurrentVersionUninstall
(每用户)
通过检查这些父键下特定条目的 UninstallString
或等效项,您可以大致了解如何通过命令行卸载相关产品.
首先尝试这种简单的方法,但请阅读以下材料以更好地了解各种安装程序的操作方式.并非所有部署工具和部署操作都在这些位置正确注册.
在注册表中的这些位置找不到应用,只有MSI 安装程序(Windows 安装程序)和一些(或大部分)旧的setup.exe 安装程序.
<小时>安装程序类型和卸载(并提取 setup.exe)
- Unattended.com":关于自动化安装/卸载主题的最简单、最快捷的阅读方式可能是:http://unattended.sourceforge.net/installers.php
- 这是陈旧的内容,但我记得它对当时的我很有帮助.
- 最重要的是,它不是我自己的内容 - 所以我不会完全链接到我自己!:-)(下面的大部分链接都是我之前的回答).对此表示歉意 - 记住你自己的内容更容易 - 你知道它存在 - 而且更容易找到.
- MSI:要处理的最标准化的包是 MSI 包(Windows 安装程序).
- 可以通过多种可靠的方式安装/卸载它们:不使用 msiexec 从命令行卸载 MSI 文件.最常见的方法是使用
msiexec.exe
命令行(链接答案中的第 3 部分).请阅读此答案.它显示了 Windows 可以调用 MSI 文件安装/卸载的多种方式(命令行
、automation
、Win32
、.NET
、WMI
、Powershell
等...) - 虽然复杂的 Windows Installer 具有许多与以前的安装技术相比,具有重大意义的企业效益.标准化命令行和用于可靠安装/卸载的可抑制 GUI是两个最重要的好处.
- 标准的 msiexec.exe 命令行
- 如何我可以找到已安装的 MSI 设置的产品 GUID 吗?
- 可以通过多种可靠的方式安装/卸载它们:不使用 msiexec 从命令行卸载 MSI 文件.最常见的方法是使用
- Setup.exe:setup.exe 格式的安装程序几乎可以是任何东西,包括打包的 MSI 文件(Windows 安装程序).对于包装在 setup.exe 文件中的 MSI 文件,您可以使用前一个要点的标准机制进行卸载(它们由产品代码 GUID 注册).下面是一些关于如何为各种类型的 setup.exe 文件提取 setup.exe 文件的内容的链接以及指向记录实际
setup 的页面的链接.exe
命令行参数:- 一般链接:这里有一些关于如何处理不同类型 setup.exe 文件的信息:从EXE中提取MSI
- Installshield:是一种用于创建旧版和现代 MSI 类型设置的工具.它提供的 setup.exe 文件实际上有许多不同的格式,有些文件具有不同的命令行开关.
- Wise:另一个重要的工具,现在已经不在市场上.许多 Wise 编译的 setup.exe 文件仍在使用中.以下是 Wise 开关的简要概述
- Advanced Installer:是当前许多人用来制作 setup.exe/安装程序的工具.http://www.advancedinstaller.com/user-guide/exe-设置文件.html
- WiX:这是一个开源工具包,用于编译 MSI 文件和 setup.exe 文件/安装程序.遇到 WiX 编译的文件是很常见的.
- WiX 安装程序 可以采用标准的 Windows 安装程序格式,例如 MSI、MSP 等...在这种情况下,请使用列出的选项在第 2 点中处理它们.
- 还有一种方法可以使用 WiX 编译
setup.exe
文件.我只知道要链接到的这个非官方列表"开关.基本的卸载格式为:setup.exe/uninstall/passive/norestart
- 您还可以打开命令提示符并转到
setup.exe/?
以获取 WiX(和其他)setup.exe
文件的参数列表.莉> - 还有一个 WiX 工具,可用于反编译 MSI 文件以及解压缩 WiX setup.exe 文件.请参阅此处的相关部分:如何比较两个(或多个)MSI 文件的内容?
- 其他工具:有许多工具可用于创建安装程序/setup.exe文件.以下是一些较大的(仅供参考 - 此处没有命令行开关,只有产品信息):
- 非 MSI 安装程序工具:http://www.installsite.org/pages/en/tt_nonmsi.htm
- Windows 安装程序工具:http://www.installsite.org/pages/en/msi/authoring.htm
- 用于部署的系统管理工具:http://www.installsite.org/pages/en/msi/admins.htm
- 这也可能有帮助:Wix -如何在没有 UI 的情况下运行/安装应用程序
- 应用:还有全新的应用世界.
<小时>
其他链接:
I am looking for a script or some cmd command to uninstall any app from my computer. I am using Windows OS. Being an automation analyst I have to constantly run automated tests for different products whenever there is new build. So every time I have to uninstall and install build which takes time.
I did try the following command:
wmic product where name="product name" call uninstall
Apparently it did work, but it didn't remove the app from control panel and also when I tried to install again it shows installation menu saying uninstall is needed. However the app's data is removed from installation directory.
No Silver Bullet
There is no silver bullet when it comes to automating installation or uninstallation - but there is a quick trick that is described in the "General Uninstall" section.
There are heaps of different flavors of installer types - and the list keeps growing. Automating them is a bit of a black art as you will be fully aware of. Not rocket science, but tedious and tiresome when things don't work reliably and there is no suitable remedy that consistently works all the time.
I have written about these issues many times before and cross-linked the content very heavily. It is messy, but if you follow the links and web of linked pages below you should be able to find the information you need for many different setup.exe and installer types.
General Uninstall
Before going into the below ad-hoc list of different types of installers / uninstallers and how to handle their command line parameters. I want to add that you can find a list of most of the products installed on the system in these registry locations:
HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstall
(64-bit)HKLMSOFTWAREWOW6432NodeMicrosoftWindowsCurrentVersionUninstall
(32-bit)HKCUSoftwareMicrosoftWindowsCurrentVersionUninstall
(per-user)
By checking for UninstallString
or equivalent for a specific entry under these parent keys, you can get a general idea of how to uninstall the product in question by command line.
Try this simple approach first, but do read the material below for a better understanding of how installers of various kinds operate. Not all deployment tools and deployment operations register properly in these locations.
Apps are not found in these locations in the registry, only MSI installers (Windows Installer) and some - or most - of legacy setup.exe installers.
Installer Types & Uninstall (and extract for setup.exe)
- "Unattended.com": The easiest and quickest read on the topic of automating install / uninstall could be this one: http://unattended.sourceforge.net/installers.php
- This is aging content, but I remember it as helpful for me back in the day.
- And crucially it is not my own content - so I don't link entirely to myself! :-) (most of the links below are earlier answers of mine). Apologizes for that - it is just easier to remember your own content - you know it exists - and it is easier to find.
- MSI: The most standardized packages to deal with are MSI packages (Windows Installer).
- They can be installed / uninstalled in a plethora of reliable ways: Uninstalling an MSI file from the command line without using msiexec. The most common approach is to use the
msiexec.exe
command line (section 3 in the linked answer). Do read this answer please. It shows the diverse ways Windows can invoke an install / uninstall for MSI files (command line
,automation
,Win32
,.NET
,WMI
,Powershell
, etc...) - Though complicated Windows Installer has a number of corporate benefits of major significance compared to previous installation technologies. Standardized command line and suppressible GUI for reliable install / uninstall are two of the most important benefits.
- The standard msiexec.exe command line
- How can I find the product GUID of an installed MSI setup?
- They can be installed / uninstalled in a plethora of reliable ways: Uninstalling an MSI file from the command line without using msiexec. The most common approach is to use the
- Setup.exe: Installers in setup.exe format can be just about anything, including wrapped MSI files (Windows Installer). For MSI files wrapped in setup.exe files you can use the previous bullet point's standard mechanisms to uninstall (they are registered by product code GUID). Below are some links on how to extract the content of setup.exe files for various types of setup.exe files and also links to pages documenting the actual
setup.exe
command line parameters:- General Links: There is some information on how to deal with different types of setup.exe files here: Extract MSI from EXE
- Installshield: is a tool used to create setups of both legacy and modern MSI types. It delivers setup.exe files that are actually in many different formats and some with differing command line switches.
- Wise: was another important tool that is now off market. Many Wise-compiled setup.exe files are still in use. Here is a brief overview of Wise switches
- Advanced Installer: is a current tool used by many to make setup.exe / installers. http://www.advancedinstaller.com/user-guide/exe-setup-file.html
- WiX: this is an Open Source toolkit used to compile MSI files and setup.exe files / installers. It is quite common to encounter WiX-compiled files.
- WiX installers can be in standard Windows Installer format such as MSI, MSP, etc... In this case use the options listed in bullet point 2 to deal with them.
- There is also a way to compile
setup.exe
files with WiX. I only know of this "unofficial list" of switches to link to. The basic uninstall format is:setup.exe /uninstall /passive /norestart
- You can also open a command prompt and go
setup.exe /?
to get a list of parameters for WiX (and other)setup.exe
files. - There is also a WiX tool that can be used to decompile MSI files and also to decompress a WiX setup.exe file. See relevant section here: How can I compare the content of two (or more) MSI files?
- Other Tools: There are many tools that can be used to create installers / setup.exe files. Here are some of the bigger ones (just FYI - no command line switches to find here, just product information):
- Non-MSI installer tools: http://www.installsite.org/pages/en/tt_nonmsi.htm
- Windows installer tools: http://www.installsite.org/pages/en/msi/authoring.htm
- Sys-admin tools for deployment: http://www.installsite.org/pages/en/msi/admins.htm
- This may also be of help: Wix - How to run/install application without UI
- Apps: And there is the whole new world of apps.
Other Links:
这篇关于在我的电脑上静默卸载和安装应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!