简体   繁体   English

此时,GOTO出乎意料

[英]GOTO was unexpected at this time

We are trying to run a custom .BAT file that has worked fine under Win98 for years, but we just got a new server over the weekend and Win98 virtual machine does not work now apparently. 我们正在尝试运行一个自定义的.BAT文件,该文件在Win98下可以正常运行多年,但是周末我们刚刚获得了一台新服务器,并且Win98虚拟机现在显然无法正常工作。 So, I'm trying to set this up so it'll work through WinXP command prompt. 因此,我正在尝试进行设置,使其可以通过WinXP命令提示符运行。 What do I need to change to make this work with XP? 为了使XP能够正常工作,我需要更改什么?

I type in the .BAT file and it runs fine. 我输入.BAT文件,它运行正常。 It allows me to type in the date, but when I type in the date as we normally do and hit enter, I get "GOTO was unexpected at this time": 它允许我键入日期,但是当我像往常一样键入日期并按回车键时,我会收到“ GOTO这时出乎意料”:

:CRLIST.BAT - DAILY C/R DEPOSIT LIST
:
@ECHO OFF
CALL SEARCH
CRDATE.EXE
IF EXIST DEPOS.LS DEL DEPOS.LS
CASHLIST.EXE
CALL QPR DEPOS.LS 2

I found GOTO in the QPR.BAT file. 我在QPR.BAT文件中找到了GOTO。 Here's the code for QPR.BAT: 这是QPR.BAT的代码:

:QPR.BAT - COPY SPECIFIED LISTING FILE ( .LS) TO SPECIFIED PRINTER PORT (1-9)
:       WITH FF FOLL'G - LPTx MUST ALREADY BE CAPTURED TO DESIRED PRINTER
:
@ECHO OFF
IF "%1==" GOTO OPERR
IF "%2==" GOTO OPERR
COPY %1 LPT%2
CALL FF%2
GOTO END

:OPERR
ECHO Please re-enter this Print Queue command as follows:
ECHO        QPR  xxxxx.LS  n
ECHO.
ECHO where  xxxxx.LS  is the name of the report listing file,
ECHO  and  n  is the Network Printer No. on which to print.
:END 

I've been reading different threads and I've tried changing "%1==" to "%1"=="" , same for %2 , and it'll then give me a new message saying: 我一直在阅读不同的线程,并且尝试将"%1=="更改为"%1"=="" ,与%2相同,然后它会给我一条新消息:

The system cannot find the specified file. 系统找不到指定的文件。
0 file(s) copied. 已复制0个文件。
The system cannot find the specified file. 系统找不到指定的文件。
0 files(s) copied. 已复制0个文件。

If I add "%%1"=="" , "%%2"=="" , and then add an extra % anywhere there is a single one, it'll display: 如果我添加"%%1"=="""%%2"=="" ,然后在只有一个的任何地方添加一个额外的%,它将显示:

The system cannot find the specified file. 系统找不到指定的文件。
The system cannot find the specified file. 系统找不到指定的文件。
0 files(s) copied. 已复制0个文件。

Do I need to provide the code for anything else? 我是否需要提供其他代码? There are a lot of .BAT files so if I can get this figured out, they hopefully we can apply to the rest of the commands. .BAT文件很多,因此,如果我能弄清楚这一点,他们希望我们可以将其应用于其余命令。

you might try this: 您可以尝试以下方法:

@ECHO OFF
IF "%~2"=="" GOTO OPERR
COPY "%~1" LPT%~2:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM