批处理文件不想被“开始”

时间:2016-09-08 22:32:30

标签: batch-file batch-processing

我搜索了网站并尝试了一些事情,但我无法解决问题。它是这样的: 我想从另一个批处理文件中启动两个批处理文件。

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

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

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

2 个答案:

答案 0 :(得分:0)

您可以使用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.

答案 1 :(得分:0)

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

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

CALL AlarmBatch.bat
CALL BackupBatch.bat

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

还要检查thisthis。这与call有关。