欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

windows 通过 bat 卸载 chrome 程序 自己亲自做的 有大用 有大大用

最好先卸载,然后重启,最后再安装,可能安装不会有问题,安装有问题的话,见  /node-admin/21537

自己亲自做的代码 ok 有大用

@echo off
setlocal

set "searchDir=C:\Program Files\Google\Chrome\Application"
set "fileName=setup.exe"
set "foundPath="

echo Searching for %fileName% in %searchDir% and its subdirectories...

rem 使用 dir 命令递归查找文件,并将结果存入变量
for /f "delims=" %%i in ('dir /s /b "%searchDir%\%fileName%"') do (
    set "foundPath=%%i"
    goto :found
)

:found
if defined foundPath (
    echo File found at: %foundPath%
    taskkill /F /IM chrome.exe
    "%foundPath%" --uninstall  --system-level --verbose-logging
) else (
   echo "C:\Program Files\ file not found"
)

set "searchDir=C:\Program Files (x86)\Google\Chrome\Application"
set "fileName=setup.exe"
set "foundPath="

echo Searching for %fileName% in %searchDir% and its subdirectories...

rem 使用 dir 命令递归查找文件,并将结果存入变量
for /f "delims=" %%i in ('dir /s /b "%searchDir%\%fileName%"') do (
    set "foundPath=%%i"
    goto :found
)

:found
if defined foundPath (
    echo File found at: %foundPath%
    taskkill /F /IM chrome.exe
    "%foundPath%" --uninstall  --system-level --verbose-logging
) else (
    echo "C:\Program Files (x86)\ file not found"
)



endlocal
pause


关于卸载上面的代码最重要的是这一句 "%foundPath%" --uninstall  --system-level --verbose-logging

(即一个可能的值为 "C:\Program Files\Google\Chrome\Application\129.0.6668.59\Installer\setup.exe" --uninstall --channel=stable --system-level --verbose-logging )



下面的可以不看了 

image.png

  1. 获取 Chrome 的卸载信息: Google Chrome 的卸载信息通常存在于注册表中。一般路径在这里:

    text
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
    HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall
    


  2. 下面红色的就是卸载字符串

  3. 您可以查找 Google Chrome 的卸载字符串。

@echo off    
echo Uninstalling Google Chrome...
taskkill /F /IM chrome.exe
"C:\Program Files\Google\Chrome\Application\129.0.6668.59\Installer\setup.exe" --uninstall --channel=stable --system-level --verbose-logging
echo Google Chrome has been uninstalled.
pause    


普通分类: