是否存在为windows卸载程序批处理



我有几个程序要从我的计算机(Windows 7 64位)上卸载。

有没有一个批处理脚本可以帮我做这件事?或者我需要从控制面板一个接一个地完成?

如果没有Windows 7,XP中有这样的东西吗?

谢谢,多尔。

据我所知,cmd中并没有真正的uninstall命令。但是,您可以查询此注册密钥

HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall

(如果你在64位机器上,可能还需要检查HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall

以查找要卸载的程序。每一个都有一个UninstallString值,它会告诉你程序卸载程序文件的路径,然后你可以通过调用它的完整路径和文件名来执行它。

如果卸载程序恰好是msi,您可以使用

msiexec /uninstall /x以静默方式卸载它。我认为这大约是你用批处理所能做的。

希望这能有所帮助!

要补充Bali的答案,请尝试以下代码。。。

@echo off
for /f "tokens=*" %%a in ('reg query hklmsoftwareMicrosoftWindowsCurrentVersionUninstall ^| find /I "%*"') do (
  for /f "tokens=1,2,*" %%b in ('reg query "%%a" /v UninstallString ^| find /I "UninstallString"') do (
    if /i %%b==UninstallString (
      echo %%d
    )
  )
)

仔细测试。然后删除echo命令。

我今天早上写了这篇文章。

@Echo off
Echo This is a batch file uninstallation program. 
Echo Run as administrator WMIC will not work. 
echo.
Echo The command [wmic product get name] will run.
Echo Looking up all installed programs...
echo. 
wmic product get name
 echo 1. First program
 echo 2. Second program
 echo 3. Third program
 echo 4. Fourth program
 echo 5. Fifth program
echo.
@echo Pick a number: 
echo. 
 choice /c:12345 
 if "%errorlevel%"=="1" wmic product where name="First program" call uninstall
 if "%errorlevel%"=="2" wmic product where name="Second program" call uninstall
 if "%errorlevel%"=="3" wmic product where name="Third program" call uninstall
 if "%errorlevel%"=="4" wmic product where name="Fourth program" call uninstall
 if "%errorlevel%"=="5" wmic product where name="Fifth program" call uninstall
Echo.
Echo.
@echo First method is done. I'll go into the alternate method. 
pause
Echo Get user input - program name?
Echo.
Echo This is an alternate method 
:input
set INPUT=
set /P INPUT=Uninstall which program?: %=%
if "%INPUT%"=="" goto input
echo Your input was: %INPUT%
echo.
echo.
Echo Uninstalling... 
echo The command [wmic product where name="%INPUT%" call uninstall] will run. 

wmic product where name="%INPUT%" call uninstall
@echo If there is "no instance" errors, then the program %INPUT% was uninstalled.
pause

从终端直接使用wmic。您可以查看微软的文档以了解更多用法。

这将是一个伟大的起点:

wmic product where vendor="Autodesk" call uninstall

我使用上面的行来清理卸载autodesk产品。

如果你不需要它是(命令行)批处理的,那么BCUninstaller非常适合在Windows中一次删除和清理许多sotfwater:https://sourceforge.net/projects/bulk-crap-uninstaller/

最新更新