2013-07-09 39 views
1
rem @echo off 
cls 
color 07 
goto start 

:initialize_chgcolor 
call :make_download 
call :make_unzip 
call :run_download 
call :run_unzip 
del chgcolor.c chgcolor.zip download.vbs unzip.vbs 2> nul 
goto :EOF 
:initialize_choice 
call :make_choice 
call :run_choice 
del ftp.commands 2> nul 
goto :EOF 
:fresh_initialize 
mkdir compatability_commands 
cd compatability_commands 
echo Creating Scripts: 
echo. 
call :initialize_chgcolor 
call :initialize_choice 
cd .. 
goto :EOF 
:make_download 
echo Creating Download Script... 
echo 'Script from http://stackoverflow.com/a/2973344/1337520 > download.vbs 
echo dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP") >> download.vbs 
echo dim bStrm: Set bStrm = createobject("Adodb.Stream") >> download.vbs 
echo xHttp.Open "GET", WScript.Arguments(0), False >> download.vbs 
echo xHttp.Send >> download.vbs 
echo. >> download.vbs 
echo with bStrm >> download.vbs 
echo  .type = 1 '//binary >> download.vbs 
echo  .open >> download.vbs 
echo  .write xHttp.responseBody >> download.vbs 
echo  .savetofile WScript.Arguments(1), 2 '//overwrite >> download.vbs 
echo end with >> download.vbs 
echo Script Created! 
echo. 
goto :EOF 
:make_unzip 
echo Creating UnZip Script... 
echo 'Extract Script In VBS > unzip.vbs 
echo 'Script From http://stackoverflow.com/a/911796/1337520 >> unzip.vbs 
echo 'The location of the zip file. >> unzip.vbs 
echo ZipFile=WScript.Arguments(0) >> unzip.vbs 
echo 'The folder the contents should be extracted to. >> unzip.vbs 
echo ExtractTo=WScript.Arguments(1) >> unzip.vbs 
echo. >> unzip.vbs 
echo 'If the extraction location does not exist create it. >> unzip.vbs 
echo Set fso = CreateObject("Scripting.FileSystemObject") >> unzip.vbs 
echo If NOT fso.FolderExists(ExtractTo) Then >> unzip.vbs 
echo fso.CreateFolder(ExtractTo) >> unzip.vbs 
echo End If >> unzip.vbs 
echo. >> unzip.vbs 
echo 'Extract the contants of the zip file. >> unzip.vbs 
echo set objShell = CreateObject("Shell.Application") >> unzip.vbs 
echo set FilesInZip=objShell.NameSpace(fso.GetAbsolutePathName((ZipFile))).items >> unzip.vbs 
echo objShell.NameSpace(ExtractTo).CopyHere(FilesInZip) >> unzip.vbs 
echo Set fso = Nothing >> unzip.vbs 
echo Set objShell = Nothing >> unzip.vbs 
echo Script created! 
echo. 
goto :EOF 
:make_choice 
echo Creating "choice.exe" script 
echo binary > ftp.commands 
echo get Services/TechNet/samples/PS/Win98/Reskit/SCRPTING/CHOICE.EXE >> ftp.commands 
echo disconnect >> ftp.commands 
echo bye >> ftp.commands 
echo "choice.exe" completed! 
echo. 
goto :EOF 
:run_download 
echo Executing Download Script... 
echo If a window opens up asking you "Do you want to open this file?", press OPEN 
echo This will allow the script to download files via HTTP. 
start /wait download.vbs http://www.mailsend-online.com/wp/chgcolor.zip chgcolor.zip 
echo Download Script Completed! 
echo. 
goto :EOF 
:run_unzip 
echo Extracting Downloaded File... 
echo If a window opens up asking you "Do you want to open this file?", press OPEN 
echo This will allow the script to extract the downloaded file. 
start /wait unzip.vbs chgcolor.zip "%CD%" 
echo Extracting Complete! 
echo. 
goto :EOF 
:run_choice 
echo Executing FTP Download... 
ftp -n -A -s:ftp.commands ftp.microsoft.com > nul 
echo FTP Download Completed! 
goto :EOF 
:intialize_KeyList 
call :write_last_modified 
echo. 
echo Creating KeyList.txt 
echo Last Modified: %time_date% > KeyList.txt 
echo ############################################### >> KeyList.txt 
echo #            # >> KeyList.txt 
echo #^>^>^>^>^>^>^>^>^>^>^>^>^>^> Serial Key List ^<^<^<^<^<^<^<^<^<^<^<^<^<^<# >> KeyList.txt 
echo #            # >> KeyList.txt 
echo ############################################### >> KeyList.txt 
echo #########THIS_SHOULD_BE_LINE_7_(SEVEN)######### >> KeyList.txt 
echo ############################################### >> KeyList.txt 
echo.>> KeyList.txt 
echo Done! 
goto :EOF 
:file_check 
if exist compatability_commands (
    if not exist compatability_commands\chgcolor.exe (
    echo CHGCOLOR.EXE is missing from the tools, downloading. 
    cd compatability_commands 
    call :initialize_chgcolor 
    cd .. 
) 
    if not exist compatability_commands\CHOICE.EXE (
    echo CHOICE.EXE is missing from the tools, downloading. 
    cd compatability_commands 
    call :initialize_choice 
    cd .. 
    ) 
) else (
    echo The required tools were not found. These files will start downloading now. 
    call :fresh_initialize 
) 

if not exist KeyList.txt (
    echo KeyList.txt was not found, generating... 
    call :intialize_KeyList 
) else (
    more +6 KeyList.txt > .tmp 
    set /P string=< .tmp 
    if not [%string%]==[#########THIS_SHOULD_BE_LINE_7_(SEVEN)#########] (
     cls 
     color CF 
     echo ERROR! YOU HAVE A MALFORMED KeyList.txt FILE! PLEASE BACKUP YOUR SERIALS, DELETE THE KeyList.txt FILE AND LAUNCH THIS PROGRAM AGAIN! 
     echo Or fix it, if you know how.... 
     echo. 
     echo Press a key to exit 
     pause > nul 
     set res=1 
     goto :EOF 
    ) 
    goto :EOF 
    ) 
:start 
echo Initializing... 
set res=0 
call :file_check 
if %res%==1 exit 
echo Else 

:get_last_modified 
set /p time_date= < KeyList.txt 
echo %time_date% 
pause 
:write_last_modified 
time /T>.tmp 
set /p time=< .tmp 
date /T>.tmp 
set /p date=< .tmp 
del /A H .tmp 
set time_date=%time% %date% 
goto :EOF 

OK, 目标代码(这个阶段):)是意外在这个时候错误

  • 能够下载的文件chgcolor.exe(在一个ZIP)和CHOICE.exe(通过FTP)在一个名为compatability_commands的文件夹中
  • 在基础目录中创建一个文件(KeyList.txt)。
  • 当脚本开始,检查线KeyList.txt 7正是: ######### THIS_SHOULD_BE_LINE_7_(SEVEN)#########
  • 输出当前的时间和日期到KeyList.txt的第一行
  • 能够检查每个文件是否存在,如果不存在,则经历下载它们的过程。

但正如标题所示,我得到)在这个时候是意外的。。 将@echo作为备注/评论关闭。它出现后

if not exist compatability_commands\CHOICE.EXE (
echo CHOICE.EXE is missing from the tools, downloading. 
cd compatability_commands 
call :initialize_choice 
cd .. 
) 
) else (

我不明白什么是错的,有足够的圆括号,除非我算错了。 请帮忙:?

PS:日志文件,如果有帮助>>HERE<<

回答

4

将行:

里面一个代码块解析器计数括号(在echo命令也)。关闭括号结束代码块。如果不是这样,请用脱字符^来避开它。

+0

啊,我看到发生了什么事。谢谢! –

+0

@AndrewWong btw:你也可以用双引号'如果不是'%string%== =='######### THIS_SHOULD_BE_LINE_7_(SEVEN)#########“(' – Endoro

+0

好的现在我有这样的编辑: echo ######### THIS_SHOULD_BE_LINE_7_(SEVEN)######### >> KeyList.txt 至 echo ######### THIS_SHOULD_BE_LINE_7_( SEVEN ^)######### >> KeyList.txt 但是当我这样做时: if“%string%”==“######### THIS_SHOULD_BE_LINE_7_(SEVEN ^)## #######“echo是的,它没有说是的 对不起,这篇文章的格式 –

相关问题