Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 在同一网络中执行两个批处理文件_Batch File_Synchronization - Fatal编程技术网

Batch file 在同一网络中执行两个批处理文件

Batch file 在同一网络中执行两个批处理文件,batch-file,synchronization,Batch File,Synchronization,我需要在同一网络中的两台不同PC机上同时执行任务。如何通过主批处理文件触发2台PC中的单个批处理文件。我看到了多种方法: 1) 在Windows中创建计划任务(我假设您正在使用Windows) 2) 通过sysinternals使用一些远程执行技术,如psexec 3) 启动程序并让它们等待通过网络发送的信号,也许检查共享驱动器上的某个文件已经足够了当“同时”表示“加/减一些(dozend)秒(取决于不同系统的时间差),计划任务就可以了 如果要同步(加上几(dozend)毫秒),请使用waitf

我需要在同一网络中的两台不同PC机上同时执行任务。如何通过主批处理文件触发2台PC中的单个批处理文件。

我看到了多种方法:

1) 在Windows中创建计划任务(我假设您正在使用Windows)

2) 通过sysinternals使用一些远程执行技术,如psexec

3) 启动程序并让它们等待通过网络发送的信号,也许检查共享驱动器上的某个文件已经足够了

当“同时”表示“加/减一些(dozend)秒(取决于不同系统的时间差),计划任务就可以了

如果要同步(加上几(dozend)毫秒),请使用
waitfor
命令。(有关更多信息,请参阅
waitfor/?

注意,这不会在其他计算机上启动任何操作,它只发送一个触发信号。如果另一端没有接收器(
waitfor
),它将不会执行任何操作)

例如:

Slave.bat(在其他计算机上运行):

蝙蝠大师

@echo off
echo sending Signal to all Computers in the Network...
REM slave.bat should be running now on other Computer(s)
REM because else they don't wait for the signal
waitfor /si StartNow
echo Signal sent.

要尝试,您也可以在同一台计算机上使用mutliple
cmd
windows,而不是在不同的计算机上使用。

听起来像是一个几乎未知的命令
waitfor
。请参阅
waitfor/?
@Stephan,如果您使用
waitfor
发布一个答案,包括一些示例代码,那将非常好(我以前从未听说过这个命令,谢谢!)…@aschipfl不会提供“为我编写代码请求?”)无论如何-看看我的答案。@Stephan,我同意……我正考虑使用
waitfor
提供一个简短的答案,因为我尝试过一点,但我不想窃取你的想法……无论如何,谢谢!
@echo off
echo sending Signal to all Computers in the Network...
REM slave.bat should be running now on other Computer(s)
REM because else they don't wait for the signal
waitfor /si StartNow
echo Signal sent.