我有一个从网络位置安装脚本的程序,它总共有(截至目前)11个不同的标志可以运行(包括那个问题)。其中一个标志是/z
,它安装名为ZoomText的应用程序。假设发生了什么,这个标志是假设set
执行安装的脚本的路径,然后从那里调用批处理脚本,实际发生的是标志输出帮助菜单。 / p>
@echo off
:: Output the banner and the version number
set "vnum=0.1.2"
if defined vnum (
if "%vnum:~4%" neq "" if "%vnum:~5%" equ "" set "vtype=dev"
if "%vnum:~2%" neq "" if "%vnum:~3%" equ "" set "vtype=stable"
)
@echo.
type "text_files\banner.txt"
@echo v%vnum%(%vtype%)
@echo.
:: Check if an argument variable is given or not
if [%1]==[] (
goto :help_menu
) else (
goto :verify_argv
)
:: verify what to install if an argument variable is given
:verify_argv
if '%1'=='/?' goto :help_menu
if '%1'=='/a' set "adobe_path=%cd%\scripts\Adobe" & goto :adobe_install
if '%1'=='/b' set "bomgar_path=%cd%\scripts\Bomgar" & goto :bomgar_install
if '%1'=='/c' set "cisco_path=%cd%\scripts\Cisco_Anyconnect" & goto :cisco_install
if '%1'=='/d' set "driver_path=%cd%\scripts\Print_Drivers" & goto :driver_install
if '%1'=='/g' set "chrome_path=%cd%\scripts\Google_Chrome" & goto :chrome_install
if '%1'=='/n' set "nscreen_path=%cd%\scripts\NetScreen" & goto :netscreen_install
if '%1'=='/r' set "r_path=%cd%\scripts\R" & goto :r_install
if '%1'=='/t' set "tab_path=%cd%\scripts\Tableau" & goto :tableau_install
if '%1'=='/z' set "zt_path=%cd\scripts\ZoomText" & goto :zt_installation
if '%1'=='/bf' set "bf_path=%cd%\scripts\BigFix_Client" & goto :bigfix_install
:: Program help menu
:help_menu
@echo. & echo.
@echo Install end user software from \\mgtutils01\windows7apps
@echo.
@echo Usage: .\utilis [PARAMS]
@echo.
@echo Parameters Description
@echo ----------- -------------
@echo /a Install Adobe software (Reader, Acrobat, Flash)
@echo /b Install Bomgar as a customer
@echo /c Install Cisco Anyconnect
@echo /d Install a print driver (HP, Ricoh, Brother, etc..)
@echo /r Install R and R Studio
@echo /g Install Google Chrome
@echo /t Install Tableau software (Reader, Desktop)
@echo /n Install NetScreen for MSHA users
@echo /z Install ZoomText
@echo /bf Install the BigFix Client
@echo "/?" Run this help and exit
@echo.
:: Had to use "/?" or else it will tell you what echo does
set /p _="Press enter to continue.."
exit
:: Install Tableau Reader or Desktop
:tableau_install
echo 1. Tableau Reader & echo 2. Tableau Publid Desktop & echo 3. Exit
set /p choice="Which would you like to install[1-3]: "
if %choice%==1 (
call "%tab_path%\tab_install.bat" /tr
) else if %choice%==2 (
call "%tab_path%\tab_install.bat" /td
) else if %choice%==3 (
exit
) else (
cls
@echo Invalid choice..
goto :tableau_install
)
:: Install adobe on the users computer
:adobe_install
echo 1. Adobe Reader & echo 2. Adobe Flash Player & echo 3. Adobe Acrobat & echo 4. Exit
set /p choice="What would you like to install[1-4]: "
if %choice%==1 (
echo Running reader installer.. & call "%adobe_path%\adobe.bat" /r
) else if %choice%==2 (
echo Running flash installer.. & call "%adobe_path%\adobe.bat" /f
) else if %choice%==3 (
echo Running acrobat installer.. & call "%adobe_path%\adobe.bat" /a
) else if %choice%==4 (
exit
) else (
cls
@echo Invalid choice..
goto :adobe_install
)
:: Install a print driver on the users system
:driver_install
echo 1. HP & echo 2. Xerox & echo 3. Canon & echo 4. Dell & echo 5. Brother & echo 6. Ricoh & echo 7. Exit
set /p printer_type="What type of printer are they using[1-7]: "
if %printer_type%==1 (
call "%driver_path%\driver.bat" hp
) else if %printer_type%==2 (
call "%driver_path%\driver.bat" xerox
) else if %printer_type%==3 (
call "%driver_path%\driver.bat" canon
) else if %printer_type%==4 (
call "%driver_path%\driver.bat" dell
) else if %printer_type%==5 (
call "%driver_path%\driver.bat" brother
) else if %printer_type%==6 (
call "%driver_path%\driver.bat" ricoh
) else if %printer_type%==7 (
exit
) else (
cls
@echo Invalid choice...
goto :driver_install
)
:: Install Zoomtext on the users system, must run as admin
:zt_installation
echo Running ZoomText installation..
call "%zt_path%\zt_install.bat"
:: Install BigFix Client on the users computer
:bigfix_install
echo Running BigFix installation..
call "%bf_path%\bf_install.bat"
:: Install Bomgar on the users system
:bomgar_install
echo Running Bomgar installation..
call "%bomgar_path%\bomgar_install.bat"
:: Install Cisco Anyconnect on the users computer
:cisco_install
echo Running Cisco Anyconnect installation..
call "%cisco_path%\anyinstall.bat"
:: Install R language and R studio on the users system
:r_install
echo Running R lang and R studio installation..
call "%r_path%\r_install.bat"
:: Install Google Chrome on the users system
:chrome_install
echo Running Google Chrome installation..
call "%chrome_path%\gchrome_install.bat"
:: Install NetScreen for MSHA users, must run as admin
:netscreen_install
echo Running NetScreen installation..
call "%nscreen_path%\nscreen_install.bat"
/z
标志不起作用的原因是什么?或者这完全是另一回事?
答案 0 :(得分:1)
if '%1'=='/z' set "zt_path=%cd\scripts\ZoomText" & goto :zt_installation
在%
中遗失%cd%
因此未按预期行事 - 无效goto