【发布时间】:2017-01-10 13:03:20
【问题描述】:
我有一个脚本:
IF "%USER_COUNTRY%"=="ie" IF NOT "%POS_TYPE%" == "ipos" ( GOTO IE_Start)
下面我有一些标签:
:PT_Start
ECHO Start PT
rem for PT Num Lock must be activated before POS start
.\native\klocks.exe +n
IF NOT EXIST c:\C3 GOTO NO_C3
pushd c:\C3\
tskill /V /A c3_net
cmd /c START /min c3_net.exe
GOTO C3_DONE
:NO_C3
ECHO C3 not present in C:\C3\
ECHO start without C3
:C3_DONE
popd
GOTO Start_Now
:IE_Start
ECHO Start IE
IF NOT EXIST c:\C3 GOTO NO_C3_RPM
pushd c:\C3\
tskill /V /A c3_rpm_net
cmd /c START c3_rpm_net.exe
GOTO RPM_C3_DONE
:NO_C3_RPM
ECHO C3 not present in C:\C3\
ECHO start without C3
:RPM_C3_DONE
popd
GOTO Start_Now
:PL_Start
ECHO Start PL
pushd c:\AModule\
cmd /c START Forcom.AModule.exe
echo "AModule ist gestartet"
popd
GOTO Start_Now
我得到:
The system cannot find the batch label specified - IE_Start
脚本在 Windows 下运行,但它保存在 Unix 上,因此它具有 LF 行结束符。我这么说是因为解决这个问题的方法很少,但我不明白为什么。我注意到以下解决了问题:
- 将换行符更改为 CR+LF(特定于 Windows);
- 将
IE_Start标签及其部分代码移到PT_Start之前; - 从
cmd /c START /min c3_net.exe中删除/min; - 将第 3 点的行改成
cmd /c START /min C:\C3\c3_net.exe(反正这个文件不存在);
发生了什么事?
【问题讨论】:
-
这是不是 bash
-
不管其他问题如何,您代码中的
:IE_Start永远不会从您发布的代码块中运行,我们知道它可以从您脚本中其他地方的GOTO运行。IF /I "%USER_COUNTRY%"=="ie" (IF /I NOT "%POS_TYPE%"=="ipos" GOTO IE_Start)。但是您确实需要包含所有代码。
标签: windows batch-file label line-endings