Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 批处理文件-查找并卸载任何现有文件µ;PC上的Torrent.exe_Windows_Batch File_For Loop_Scripting_Uninstallation - Fatal编程技术网

Windows 批处理文件-查找并卸载任何现有文件µ;PC上的Torrent.exe

Windows 批处理文件-查找并卸载任何现有文件µ;PC上的Torrent.exe,windows,batch-file,for-loop,scripting,uninstallation,Windows,Batch File,For Loop,Scripting,Uninstallation,我是新来的,我是一批新手 我通过Microsoft InTune管理大约10000台PC,我发现其中大约500台安装了uTorrent,由于uTorrent的功能和安全风险,我需要将其删除 基本上,我想做的是在整个C:/Drive中搜索“µTorrent.exe”,找到它,卸载它,删除它曾经存在的任何存在,并继续循环,直到删除所有与µTorrent相关的文件。如果可能的话,从注册表中删除任何条目 我可以在CMD窗口中运行所有这些命令,因此我认为这是一个格式错误,因此当尝试批量编译它们时,在以下情

我是新来的,我是一批新手

我通过Microsoft InTune管理大约10000台PC,我发现其中大约500台安装了uTorrent,由于uTorrent的功能和安全风险,我需要将其删除

基本上,我想做的是在整个C:/Drive中搜索“µTorrent.exe”,找到它,卸载它,删除它曾经存在的任何存在,并继续循环,直到删除所有与µTorrent相关的文件。如果可能的话,从注册表中删除任何条目

我可以在CMD窗口中运行所有这些命令,因此我认为这是一个格式错误,因此当尝试批量编译它们时,在以下情况下似乎无法完成:

然后它失败了

顺便说一句,我不能使用WMIC卸载软件,因为uTorrent本身安装在哪里

我将发布我在该主题上找到的一些信息:

HKCU\软件\t当前

HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\µTorrent µTorrent/forceuninstall

显示名称:µTorrent

版本:3.4.5.41628

安装位置:%APPDATA%\Roaming\t当前

出版商:比特洪流公司

卸载字符串:“%APPDATA%\Roaming\uTorrent\uTorrent.exe”/Uninstall

注册表位置:计算机\HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\µTorrent

HKEY\U CURRENT\U USER\Software\Microsoft\Windows\CurrentVersion\Uninstall\uTorrent

uTorrent.exe的文件位置C:\Users\Cricketadmin\AppData\Roaming\uTorrent

删除uTorrent客户端:删除exe: 删除用户\%users\appdata\roaming\t当前

C:/%USER%\AppData\Roaming\uTorrent\uTorrent.exe C:\ProgramFiles\uTorrent\uTorrent.exe

目录/S C:*µTorrent.exe 应该是

Call "%p%" /Uninstall /S /Q 
IF NOT EXIST "%p%" (
exit /b %errorlevel%
防止
%p%
中出现分隔符(如空格…)

这将执行
exit
命令并终止此
cmd
实例-除非它反对
cmd
部分(其目的是做什么?),在这种情况下它将生成错误消息

关键是,
goto
将不会执行,因为
cmd
会话将终止

IF NOT EXIST %p% (
应该是

Call "%p%" /Uninstall /S /Q 
IF NOT EXIST "%p%" (
exit /b %errorlevel%
对于分离器,原因相同

EXIST /B
EXIT Errorlevel
END
这三条线毫无意义
exist
不是标准命令(除非它是某个已知的可执行文件)
exit errorlevel
可能意味着将errorlevel返回到调用此例程的位置。应该是

exit /b %errorlevel%
end
不是有效的标准命令,在任何情况下都不会执行,因为上一个命令是
exit

哦-顺便说一句:

del /s c:\utorrent.exe /q /f

将删除
c:
上的所有
utorrent.exe
文件。使用时要格外小心,因为一个小的tyop可能会产生不良后果。

我已经编写了下面的脚本,它将完全删除软件uTorrent的任何痕迹

@Echo Off
CLS
TITLE Find and Uninstall Bad SoftWare
setlocal ENABLEDELAYEDEXPANSION
setlocal ENABLEEXTENSIONS
:Part1
SET "BAD=µTorrent.exe"
SET "Z="
For /f "delims=" %%A IN ('Dir /B /S "C:\*uTorrent.exe" 2^>NUL') Do Set Z=%%A
IF DEFINED Z (
GoTo :Part2
) Else (
GoTo :Part2
)
GoTo :Part2
:Part2
IF DEFINED Z (
"!Z!" /UNINSTALL /S >nul 2>&1
GoTo :Part1
) ELSE (
GoTo :Part3
)
GoTo :Part3
:Part3
SET "Z="
For /F "delims=" %%A IN ('Dir /B /S "C:\*Torrent*" 2^>NUL') Do Set Z=%%A
IF DEFINED Z (
Del /F /S /Q "!Z!" >nul 2>&1
RD /S /Q "!Z!" >nul 2>&1
GoTo :Part3
) Else (
GoTo :Part4
)
GoTo :Part4
:Part4
ChDir /D C:\
For /F "delims=" %%A IN ('Dir /B /S "C:\users\*.TMP*" 2^>NUL') Do (
Del /F /S /Q "%%A" >nul 2>&1
)
ChDir /D C:\
For /F "delims=" %%A IN ('Dir /B /S "C:\Windows\*.TMP*" 2^>NUL') Do (
Del /F /S /Q "%%A" >nul 2>&1
)
ChDir /D C:\
For /F "delims=" %%A IN ('Dir /B /S "C:\*.TMP*" 2^>NUL') Do (
Del /F /S /Q "%%A" >nul 2>&1
)
ChDir /D C:\
For /F "delims=" %%A IN ('Dir /B /S "C:\Windows\Temp\*.*" 2^>NUL') DO (
Del /F /S /Q "%%A" >nul 2>&1
RD /S /Q "C:\Windows\Temp\" >nul 2>&1
)
ChDir /D C:\
For /F "delims=" %%A IN ('Dir /B /S "C:\Windows\Prefetch\*.*" 2^>NUL') DO (
Del /F /S /Q "%%A" >nul 2>&1
RD /S /Q "C:\Windows\Prefetch\" >nul 2>&1
)
ChDir /D C:\
For /F "delims=" %%A IN ('Dir /B /S ^"C:\Users\%username%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*^" 2^>NUL') DO (
Del /F /S /Q "%%A" >nul 2>&1
RD /S /Q "C:\Users\%username%\AppData\Local\Microsoft\Windows\Temporary Internet Files\" >nul 2>&1
)
ChDir /D C:\
For /F "delims=" %%A IN ('Dir /B /S "C:\%temp%" 2^>NUL') DO (
Del /F /S /Q "%%A" >nul 2>&1
RD /S /Q "C:\TEMP\" >nul 2>&1
)
ChDir /D C:\
DEL /F /S /Q %temp%\ >nul 2>&1
ChDir /D C:\
For /F "delims=" %%A IN ('Dir /B /S "C:\*.TMP*" 2^>NUL') DO (
Del /F /S /Q "%%A" >nul 2>&1
)
ChDir /D C:\
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 >nul 2>&1
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2 >nul 2>&1
:Part5
SET "R="
For /F "delims=" %%B IN ('Dir /B /S "C:\$Recycle.Bin\*" 2^>NUL') Do Set R=%%B
IF DEFINED R (
Del /F /S /Q "!R!" >nul 2>&1
RD /S /Q "!R!" >nul 2>&1
GoTo :Part5
) Else (
GoTo :Part6
)
:Part6
Set "RegKey=HKCR"
Set "SearchWord=*Torrent*"
For /F "tokens=*" %%A In ('REG QUERY "%RegKey%" /F "%SearchWord%" /S ^| Find /I "Key" ^| Sort') Do (
For /F "tokens=* delims= " %%B In ("%%A") Do Set "Name=%%B"
Set "Name=!Name!"
For /F "delims=@" %%B In ("!Name!") Do (
    REG DELETE "!Name!" /F >nul 2>&1
)
)
GoTo :Part7
:Part7
Set "RegKey=HKCU"
Set "SearchWord=*Torrent*"
For /F "tokens=*" %%A In ('REG QUERY "%RegKey%" /F "%SearchWord%" /S ^| Find /I "Key" ^| Sort') Do (
For /F "tokens=* delims= " %%B In ("%%A") Do Set "Name=%%B"
Set "Name=!Name!"
For /F "delims=@" %%B In ("!Name!") Do (
    REG DELETE "!Name!" /F >nul 2>&1
)
)
GoTo :Part8
:Part8
Set "RegKey=HKLM"
Set "SearchWord=*Torrent*"
For /F "tokens=*" %%A In ('REG QUERY "%RegKey%" /F "%SearchWord%" /S ^| Find /I "Key" ^| Sort') Do (
For /F "tokens=* delims= " %%B In ("%%A") Do Set "Name=%%B"
Set "Name=!Name!"
For /F "delims=@" %%B In ("!Name!") Do (
    REG DELETE "!Name!" /F >nul 2>&1
)
)
GoTo :Part9
:Part9
Set "RegKey=HKU"
Set "SearchWord=*Torrent*"
For /F "tokens=*" %%A In ('REG QUERY "%RegKey%" /F "%SearchWord%" /S ^| Find /I "Key" ^| Sort') Do (
For /F "tokens=* delims= " %%B In ("%%A") Do Set "Name=%%B"
Set "Name=!Name!"
For /F "delims=@" %%B In ("!Name!") Do (
    REG DELETE "!Name!" /F >nul 2>&1
)
)
GoTo :Part10
:Part10
Set "RegKey=HKCC"
Set "SearchWord=*Torrent*"
For /F "tokens=*" %%A In ('REG QUERY "%RegKey%" /F "%SearchWord%" /S ^| Find /I "Key" ^| Sort') Do (
For /F "tokens=* delims= " %%B In ("%%A") Do Set "Name=%%B"
Set "Name=!Name!"
For /F "delims=@" %%B In ("!Name!") Do (
    REG DELETE "!Name!" /F >nul 2>&1
)
)
GoTo :Part11
:Part11
ENDLocal
Exit /b %errorlevel%
END

最后

只需将其放入批处理文件
%APPDATA%\Roaming\uTorrent\uTorrent.exe”/UNINSTALL
。这就是你所需要做的-它将卸载或失败。如果您关心是否无需卸载,请尝试
%APPDATA%\Roaming\uTorrent\uTorrent.exe”/uninstall&&Echo Uninstalled | | Echo未安装
此处有关于此脚本问题的注释: