我是新来的,我是批量新手。
我通过Microsoft InTune管理大约10,000台PC,我发现其中约有500台安装了uTorrent,因为uTorrent的功能和安全风险,我需要将其删除。
基本上我想要做的是搜索整个C:/ Drive中的“μTorrent.exe”,找到它,卸载它,删除它曾经存在的任何存在并继续循环直到所有的μTorrent相关文件被删除。如果可能,可能会从注册表中删除任何条目。
我可以在A CMD窗口中运行所有这些命令,所以我认为这是一个格式错误,所以当试图批量编译它们时,它似乎没有完成:
Call %p% /Uninstall /S /Q
Echo %p%
然后失败了。
顺便说一下,由于uTorrent安装在哪里,我无法使用WMIC卸载软件。
我将在这个主题上发布一些信息:
HKCU \ SOFTWARE \ uTorrent的
HKCU \软件\微软\的Windows \ CurrentVersion \卸载\的μTorrent μTorrent/ forceuninstall
显示名称:μTorrent
版本:3.4.5.41628
安装位置:%APPDATA%\漫游\ uTorrent
出版商:Bit Torrent Inc。
卸载字符串:“%APPDATA%\ Roaming \ uTorrent \ uTorrent.exe”/ UNINSTALL
注册表位置:计算机\ HKCU \ Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \μTorrent
HKEY_CURRENT_USER \软件\微软\的Windows \ CurrentVersion \卸载\ uTorrent的
uTorrent.exe的文件位置C:\ Users \ Cricketadmin \ AppData \ Roaming \ uTorrent
删除uTorrent客户端:删除exe: 删除用户\%用户 \ appdata \ roaming \ utorrent
C:/%USER%\应用程序数据\漫游\的uTorrent \ uTorrent.exe C:\ Program Files \ uTorrent \ utorrent.exe
Dir / S C:*μTorrent.exe< ---将在整个c:/
上显示μTorrent.exe的任何实例
下面我已经发布了我目前编译的内容:
@echo OFF
CLS
TITLE Find and Uninstall µTorrent.exe
setlocal ENABLEDELAYEDEXPANSION
setlocal ENABLEEXTENSIONS
REM This Batch Program will Find and Uninstall µTorrent.exe
GoTo :LOOP1
:LOOP1
REM This loop will search all of the C:/ to find the "µTorrent.exe" file, and Uninstall "µTorrent.exe" if found.
For /R C:\ %%A IN (*) Do IF "%%~nxA"=="utorrent.exe" Set p=%%~dpnxA
IF DEFINED p (
Echo %p%
Call %p% /Uninstall /S /Q
Echo %p%
DEL /F /S /Q %p%
Echo %p%
GoTo :LOOP1
) Else (
Echo File not found & EXIT CMD
GoTo :LOOP2
)
:LOOP2
REM This loop will end the batch!
IF NOT EXIST %p% (
Echo %p% File not found & EXIT CMD
) ELSE (
Echo %p%
)
ENDLocal
EXIST /B
EXIT Errorlevel
END
REM I also need to be able to delete the desktop icon <- this is a reminder to me.
REM I would like to some how incorporate "Dir /S C:\*ipscan24.exe" into this Batch Script and use the results as a Variable(s).
答案 0 :(得分:0)
Call %p% /Uninstall /S /Q
应该是
Call "%p%" /Uninstall /S /Q
防止%p%
中的分隔符(如空格....)
) Else (
Echo File not found & EXIT CMD
GoTo :LOOP2
)
这将执行exit
命令并终止此cmd
实例 - 除非它反对cmd
部分(打算做什么?)在哪种情况下它会生成一个错误信息。
点是,goto
将不会被执行,因为cmd
会话将终止
IF NOT EXIST %p% (
应该是
IF NOT EXIST "%p%" (
相同的in case of separators
原因。
EXIST /B
EXIT Errorlevel
END
这三行没什么意义。 exist
不是标准命令(除非它是某些已知的可执行文件)。 exit errorlevel
可能意味着将errorlevel返回到调用此例程的任何内容。它应该是
exit /b %errorlevel%
end
不是有效的标准命令,并且在任何情况下都不会执行,因为上一个命令是exit
。
哦 - 顺便说一句:
del /s c:\utorrent.exe /q /f
会删除utorrent.exe
上的所有c:
个文件。使用极端谨慎,因为一个小的错误可能会产生不良后果。
答案 1 :(得分:0)
我制作了以下脚本,它将完全删除软件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
结束