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
好的,代码目标(此阶段):
- 能够在名为 compatability_commands 的文件夹中下载文件 chgcolor.exe(在 ZIP 中)和 CHOICE.exe(通过 FTP)
- 在基本目录中创建一个文件 (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:日志文件如果有帮助>>这里<<