批处理文件不想被“启动”

Batch file doesnt want to be 'START'ed

我在网站上搜索并尝试了一些方法,但无法解决问题。就像这样: 我想从另一个批处理文件启动两个批处理文件。

START %ScriptAlarmDrive%
//Also tried CALL %ScriptAlarmDrive% (with EXIT /B in Alarm then)
CALL %ScriptBackupDrive%

当我单独启动 Alarm Batch 或 Backup Batch 时,它们运行良好。

IF %Month% == 7 goto EchoExams
IF %Month% == 9 goto EchoNewSemester
EXIT

:EchoExams
ECHO -----Klausurentermine:
TYPE %SOURCEEXAMS% |more
ECHO. & ECHO. & PAUSE & EXIT

:EchoNewSemester
ECHO -----Im neuen Semester zu beachten:
TYPE %SourceNewSemesterTakeNote% |more
ECHO. & ECHO.
ECHO -----Informationen zum neuen Semester:
TYPE %SourceNewSemesterInformation% |more
ECHO. & ECHO. & PAUSE & EXIT

和备份批处理文件:

ECHO -----Backup
XCOPY %SOURCE% %DEST% %PARA%
ECHO. enter code here

但是,如果我启动第一个批处理文件,则只会执行备份,而不会从警报中获得输出。

如果有人能帮助我,我将不胜感激。 萌

您可以同时使用 start 和 运行 这两个批处理文件。您可以按顺序使用 call 到 运行 它们(因为它们是批处理文件)。不需要 exit /b,因为批处理最终会退出。

Starting a Program
===============

See start /? and call /? for help on all three ways.

Specify a program name
--------------------------------

    c:\windows\notepad.exe

In a batch file the batch will wait for the program to exit. When
typed the command prompt does not wait for graphical
programs to exit.

If the program is a batch file control is transferred and the rest of the calling batch file is not executed.

Use Start command
--------------------------

    start "" c:\windows\notepad.exe

Start starts a program and does not wait. Console programs start in a new window. Using the /b switch forces console programs into the same window, which negates the main purpose of Start.

Start uses the Windows graphical shell - same as typing in WinKey + R (Run dialog). Try 

    start shell:cache

Use Call command
-------------------------

Call is used to start batch files and wait for them to exit and continue the current batch file.

您可以从一个 .bat 脚本中调用这两个 .bat 脚本。

复制下面的脚本并将其粘贴到CALL.bat

CALL AlarmBatch.bat
CALL BackupBatch.bat

命名您拥有的两个脚本 AlarmBatch.batBackupBatch.bat 确保这些脚本都在同一个文件夹中然后 运行 CALL.bat

同时检查 this and this。这一切都与call有关。