2015-01-26 2 views
0

나는이 책을 썼다.하지만 약간의 도움이 필요하다. 아래의 코드는 전체이지만, 옵션 2가 고통 인 것처럼 작은 덩어리로 분해 할 것입니다. 내가 옵션 위에서 말했듯이IE 11 파일을 삭제하는 일괄 스크립트

@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는 For /F 때까지 나에게 예 모두 ") was unexpected at this time" 및 제

:loc 

작품을 제공하고있다 그게 전부 실패하고 오류를 던져 결정한다. 하지만 내가하려는 것은 이름의 파일을 읽고 거기에 파일이 있는지 확인하는 것입니다. 그렇지 않으면 다음으로 루프하십시오. 문제

블록 :

: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 
+1

괄호 안의 코드 블록 내에서 코멘트 마커로'::'를 사용하려고 할 수 있습니다. 코드 블록 내에서 주석을 표시하려면'rem'을 사용해야합니다. 원하는 경우'rem ::'을 사용하십시오. 그럼에도 불구하고'rem'을 사용하십시오. 엄밀히 말하자면, 대부분의 경우 배치 스크립트에서 주석을 나타내는'::'을 볼 때, 실제로는 사용되지 않은 레이블입니다. 그러나 괄호 안의 코드 블록 안에 레이블을 붙이려고하면 오류가 발생합니다. – rojo

+0

모두 변경되었습니다. 나는'::'이 나쁘다는 것을 알지 못했다. 고마워요 – Benny

답변

1

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" 

rem:: 유해에 로조의 조언을 따르십시오.

+0

아아 그래서 나는 파일에서'%'의 쓰레기통을 놓쳤습니다. 그들 모두가 바뀌었고 지금은 새끼 고양이처럼 손질하고있어. 고맙습니다. 원하는 경우 나중에 IE 업그레이드 실패를 대비하여 완성 된 파일을 게시 할 수 있습니다. – Benny

관련 문제