Batch file 在子命令提示符中批处理运行命令

Batch file 在子命令提示符中批处理运行命令,batch-file,command-prompt,Batch File,Command Prompt,我的批处理文件中有以下内容,需要通过Windows任务计划程序运行。这是一个示例脚本 @echo off echo This is parent command prompt <some external executable with some arguments> & REM This launches another command prompt with special environment variables set REM I want the follo

我的批处理文件中有以下内容,需要通过Windows任务计划程序运行。这是一个示例脚本

@echo off
echo This is parent command prompt
<some external executable with some arguments>   & REM This launches another command prompt with special environment variables set

REM I want the following command to be run in the command prompt that got launched above
echo This is child command prompt

您能否向我们提供真实的信息,以便我们能够复制您的特定问题,
不够具体,我们无法以任何程度的确定性帮助您。我将假设您的秘密外部可执行文件正在启动cmd.exe窗口,因为您是如何调用它的。因此,关于您的问题,这些信息是您能提供给我们的最重要的信息。@Compo我添加了一个简单的示例,因为提供秘密可执行文件是没有意义的,因为它对世界是不可用的。顺便说一句,您的“简单”示例不是有效代码,因此不像您想象的那么简单!我们需要准确地了解您是如何运行计划任务的,以及在什么标准下运行的,并且通过一个真实的示例来解释您试图实现的目标,说明实际发生的事情以及意图是什么。目前,您正在一个网站上询问一个常规编程问题,该网站致力于帮助您解决所提供代码的单个特定问题。鉴于您现在修改的简单示例,从Windows任务计划程序调用以下单行批处理文件:
@Echo这是父命令提示符&(启动“子命令提示符”%\uuuuuu AppDir\uuuuuu%cmd.exe)/D/Q/K“Echo hello&Echo This is child command prompt”)&Pause
,将完全满足您的要求。它回答了你的问题吗?或者你的例子不能代表你在现实世界中的任务?就在我迷路的帖子中的“或”之后。你能澄清这个问题吗?听起来您只需要一些简单的“转到”例程,或者只需对另一个bat文件进行“调用”。
@echo off
echo This is parent command prompt
start cmd.exe @cmd /k "echo hello" & REM This launches another command prompt

REM I want the following commands to be run in the command prompt that got launched above
echo This is child command prompt