删除 IE 11 文件的批处理脚本

Batch script to Delete an IE 11 File

我写这篇文章是出于无聊,但我需要一点帮助。下面的代码是完整的,但我会把它分成更小的块,因为选项 2 很麻烦。

@echo off
Set SQMFile="C$\Users\Default\AppData\Local\Microsoft\Windows\Temporary Internet Files\SQM"
Set CSVFile="%userprofile\Documents"
:top
cls
echo.
echo You upgraded to IE 11 and now you can't login
echo follow the prompts below and I will fix it 
echo for you :)
echo.
echo.
echo 1) Single Computer? 
echo 2) Multiple Computers? (txt file)
echo 3) Help menu
echo. 
echo.
Set /p C="What do you want to do? "
if %C%==1 goto opt1
if %C%==2 goto opt2
if /i %C%==3 goto help
::===================================================================
:opt1
Set /p comname="Whats the computer name? "
if exist "\%comname%\%SQMFile\iesqmdata_setup0.sqm" (
    echo File is there...
    echo Deleting File
    del "\%comname%\%SQMFile\iesqmdata_setup0.sqm" 
    goto top
) else (
    echo File is not there
    goto top
)
::===================================================================
:opt2
Set /p opt2="Is the file in your Documents folder named Computers.txt? (Y/N) "
if /i %opt2%==y goto file
if /i %opt2%==n goto loc
::===================================================================
:loc
cls
echo Where's the file located and what's it called?
echo example "C:\users\<username>\documents\list of comptures.txt"
set /p newloc="No need for quotes: "
echo In File label
pause
for /F %%G in ("%newloc%") DO (
    if exist "\%%G\%SQMFile\iesqmdata_setup0.sqm" (
    echo File is there
    pause
    ::del "\%%G\%SQMFile\iesqmdata_setup0.sqm"
    ) else ( 
    echo File is not there
    )
)
Pause
goto top
::===================================================================
:file
echo In File label
pause
for /F %%G in ("%CSVFile%\Computers.txt") DO (
    if exist "\%%G\%SQMFile\iesqmdata_setup0.sqm" (
    echo File is there
    ::del "\%%G\%SQMFile\iesqmdata_setup0.sqm"
    ) else ( 
    echo File is not there
    )
)
Pause
goto top
::===================================================================
:help
cls
echo.
echo.
echo =================Help Menu===========================
echo This script is used only for deleting the .sqm
echo file that likes to break the "User Logon Service"
echo for computers after updating to IE 11
echo.
echo Option 1 is for single computers.
echo It checks for the file and if there it
echo deletes it.
echo.
echo Option 2 does the same as 1 but is more geared towards 
echo mass amounts of computers. a multi line, single entry
echo file is supported ex:Line1
echo                 Line2
echo                 Line3
echo Please save the file in %userprofile%\Documents
echo with the file name Computers.txt
echo =====================================================
echo.
echo.
Pause 
goto top

:eof

所以正如我上面所说,选项 2 给了我 ") was unexpected at this time" 是和否。

:loc

一直工作到 For /F,这就是决定失败并抛出错误的地方。 但我想做的是读取名称文件并检查文件是否存在并将其删除。如果没有则循环到下一个。

有问题的区块:

:opt2
Set /p opt2="Is the file in your Documents folder named Computers.txt? (Y/N) "
if /i %opt2%==y goto file
if /i %opt2%==n goto loc
::===================================================================
:loc
cls
echo Where's the file located and what's it called?
echo example "C:\users\<username>\documents\list of comptures.txt"
set /p newloc="No need for quotes: "
echo In File label
pause
for /F %%G in ("%newloc%") DO (
    if exist "\%%G\%SQMFile\iesqmdata_setup0.sqm" (
    echo File is there
    pause
    ::del "\%%G\%SQMFile\iesqmdata_setup0.sqm"
    ) else ( 
    echo File is not there
    )
)
Pause
goto top
::===================================================================
:file
echo In File label
pause
for /F %%G in ("%CSVFile%\Computers.txt") DO (
    if exist "\%%G\%SQMFile\iesqmdata_setup0.sqm" (
    echo File is there
    ::del "\%%G\%SQMFile\iesqmdata_setup0.sqm"
    ) else ( 
    echo File is not there
    )
)
Pause
goto top

if exist "\%%G\%SQMFile\iesqmdata_setup0.sqm" ((以及更多)中缺少 %。应该是

if exist "\%%G\%SQMFile%\iesqmdata_setup0.sqm" (

并去掉结束 :eof 标签...这是一个 预定义 标签,它将退出当前例程。要退出批处理脚本文件或退出子例程,请指定 GOTO :eof 这会将控制转移到当前批处理文件的末尾或当前子例程的末尾。

编辑:

Set "SQMFile=C$\Users\Default\AppData\Local\Microsoft\Windows\Temporary Internet Files\SQM"
Set "CSVFile=%userprofile%\Documents"

遵循 rojo 关于 rem 与有害 ::.

的建议