Uninstall and Install App on my Computer silently

…衆ロ難τιáo~ 提交于 2019-12-17 14:41:30

问题


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.


回答1:


I figured it out myself and it works for many projects which have .exe setups. Following is the format 1. Open terminal with admin rights 2. go to path in where setup that you used to install the product. 3. Once there then type: setupname.exe /uninstall /q




回答2:


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:

  • HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall (64-bit)
  • HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall (32-bit)
  • HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall (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)

  1. "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.
  2. 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?
  3. 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.
      • There is a description of Installshield setup.exe peculiarities here
      • Here is the official documentation for Installshield setup.exe files
      • Here is a simple explanation of setup.exe extraction for Installshield setup.exe files
    • 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?
  4. 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
  5. Apps: And there is the whole new world of apps.
    • How to silent install an UWP appx?
      • Add-AppxPackage
      • Remove-AppxPackage
    • Install UWP apps with App Installer
    • Install Windows Store App package (*.appx) for all users
    • Install package (appxbundle) via .appinstaller to all users on machine

Other Links:

  • How to create windows installer


来源:https://stackoverflow.com/questions/49422777/uninstall-and-install-app-on-my-computer-silently

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!