我的批處理腳本抱怨說它找不到路徑(不確定它是什麼路徑,因爲它不太精確,解釋它有什麼問題。是:批處理文件 - VBScript運行時錯誤:找不到路徑
C:/Users/Boss/AppData/Local/Temp/_.vbs(3, 1) Microsoft VBScript runtime error: Path not found
這個腳本的整個想法是donwload tomcat的(而不是隻)放置在指定的目錄,解壓並進行設置,現在由於某種原因,解壓方法工作完全正常下載和unziping Ant,但是對於Tomcat而言,它並不是。下面是installAnt和installTomcat方法以及UnZip方法。
:installAnt
::----- ANT Section -----::
:: Setup Apache Ant if Ant does not exist
md "%HOMEDRIVE%\Apache\apache-ant-1.9.7\" 2>nul
:: Set filename variable
SET "FILENAME=%~dp0\apache-ant-1.9.7-bin.zip"
:: Download ANT from mirror
bitsadmin.exe /transfer "Apache Ant Download" http://mirrors.ukfast.co.uk/sites/ftp.apache.org//ant/binaries/apache-ant-1.9.7-bin.zip "%FILENAME%"
:: Copy Apache Ant to C:\Apache
xcopy "%~dp0apache-ant-1.9.7-bin.zip" "%HOMEDRIVE%\Apache\."
:: Delete zip file from curent directory
del "%~dp0apache-ant-1.9.7-bin.zip"
:: Unzip Apache Ant to C:\Apache
call :UnZipFile "%HOMEDRIVE%\Apache\" "%HOMEDRIVE%\Apache\apache-ant-1.9.7-bin.zip"
:: Delete zip folder
del "%HOMEDRIVE%\Apache\apache-ant-1.9.7-bin.zip"
:: Set ANT_HOME path
set "ANT_HOME=%HOMEDRIVE%\Apache\apache-ant-1.9.7"
setx ANT_HOME "%HOMEDRIVE%\Apache\apache-ant-1.9.7" /m
:: Add ANT to path
set "path=%PATH%;%ant_home%\bin"
setx path "%PATH%" /m
goto checkIvy
:installTomcat
::----- Tomcat Section -----::
echo Installing tomcat
:: Setup Apache Tomcat if Tomcat does not exist
md "%HOMEDRIVE%\Apache\apache-tomcat-7.0.56\" 2>nul
:: Set filename variable
SET "FILENAME=%~dp0\apache-tomcat-7.0.56.zip"
:: Download Tomcat from mirror
bitsadmin.exe /transfer "Apache Tomcat Donwload" http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.56/bin/apache-tomcat-7.0.56.zip "%FILENAME%"
:: Copy Apache Tomcat to C:\Apache
xcopy "%~dp0apache-tomcat-7.0.56.zip" "%HOMEDRIVE%\Apache\."
:: Delete zip file from curent direcotry
del "%~dp0apache-tomcat-7.0.56.zip"
:: Unzip Apache Tomcat to C:\Apache
call :UnZipFile "%HOMEDRIVE\Apache\" "%HOMEDRIVE%\Apache\apache-tomcat-7.0.56.zip"
pause
rem :: Delete zip folder
rem del "%HOMEDRIVE%\Apache\apache-tomcat-7.0.56.zip"
rem :: Set TOMCAT_HOME
rem set "TOMCAT_HOME=%HOMEDRIVE%\Apache\apache-tomcat-7.0.56"
rem setx TOMCAT_HOME "%HOMEDRIVE%\Apache\apache-tomcat-7.0.56" /m
rem :: Add TOMCAT to path
rem set "path=%PaTH%;%tomcat_home%\bin"
rem setx path "%PATH%" /m
解壓縮功能:
:: Unzip file
:UnZipFile <ExtractTo> <newzipfile>
set vbs="%temp%\_.vbs"
if exist %vbs% del /f /q %vbs%
>%vbs% echo Set fso = CreateObject("Scripting.FileSystemObject")
>>%vbs% echo If NOT fso.FolderExists(%1) Then
>>%vbs% echo fso.CreateFolder(%1)
>>%vbs% echo End If
>>%vbs% echo set objShell = CreateObject("Shell.Application")
>>%vbs% echo set FilesInZip=objShell.NameSpace(%2).items
>>%vbs% echo objShell.NameSpace(%1).CopyHere(FilesInZip)
>>%vbs% echo Set fso = Nothing
>>%vbs% echo Set objShell = Nothing
cscript //nologo %vbs%
if exist %vbs% del /f /q %vbs%
goto :eof
可惜我不是用批處理文件的專家,我有麻煩弄清楚爲什麼它的工作原理爲Ant而不是Tomcat的方法。
該批處理文件的第3行:
:: @Author: Maciej Cygan
錯誤來自生成的VBScript,而不是來自批處理文件。該文件的第3行是什麼樣的? –
@AnsgarWiechers它只是一個評論真正的更新 –
生成的VBScript的第3行,** NOT **批處理文件。 –