在 Windows bat 文件中运行另一个程序并且不创建子进程
我有一个带有提交后挂钩的颠覆服务器来执行某些操作。
我希望签入尽快完成,而不是等待挂钩脚本。 但根据设计,Subversion 提交后挂钩脚本将一直运行,直到所有子进程退出,因此在挂钩 bat 文件中使用类似:
start another_prog... 的
内容没有用。
所以我想知道如何在 Windows bat 文件中运行另一个程序,该程序不创建子进程或让子进程与父进程分离。
I have subversion server with a post-commit hook to do something.
I want the checkin finish soon, not wait the hook script.
But by design, the Subversion post-commit hook script will run until all child process exit, so using somthing like:
start another_prog...
in the hook bat file has no use.
So I want to know how to run another program in Windows bat file which not create child process or let the child process detach from the parent.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
同步。在关闭第一个记事本之前,第二个记事本不会启动。
异步:即使您尚未关闭第一个记事本,第二个记事本也会启动。
有关启动命令的更多信息:
http://www.robvanderwoude.com/ntstart.php
编辑 :以下评论是原发帖者@zhongshu在别处发表的。我只是复制在这里:
假设他知道他在说什么,我就错了,而且……不值得。
Synchronous. The second notepad won't launch until you close the first.
Asynchronous: The second notepad will launch even if you haven't closed the first.
More info about the start command:
http://www.robvanderwoude.com/ntstart.php
EDIT: The following comment was made elsewhere by @zhongshu, the original poster. I'm only copying it here:
Assuming that he knows what he's talking about, I'm wrong and...undeserving.
我找到了一个方法来解决我的问题,编译以下c代码并将exe输出命名为runjob.exe,然后在hook bat文件中,使用“ runjob another_prog ”,现在就可以了。
I found a method to resolve my question, compile the following c code and named the exe output as runjob.exe, and then in the hook bat file, use " runjob another_prog " , now it's ok.
您可以做的是创建一个计划任务来执行批处理脚本或其他长时间运行的可执行文件。将其设置为过去运行一次,并且不要将其设置为在不再计划运行时删除任务。然后在您的 Subversion 挂钩脚本中,放入以下行:
我通过让计划任务运行 Notepad++ 进行测试来确认,并且 Notepad++ 可执行文件显示为 svchost.exe 的子项,而不是我执行 < 的 cmd.exe 窗口。代码>schtasks 命令来自。
What you can do is create a Scheduled Task that executes the batch script or other executable that runs for a long time. Set it to run once, in the past and don't set it to delete the task when no more runs are scheduled. Then in your Subversion hook script, put the following line in:
I confirmed with a test by having my scheduled task run Notepad++ and the Notepad++ executable showed up as a child of svchost.exe, not the cmd.exe window that I executed the
schtasks
command from.使用:
干杯。
Use:
Cheers.
尝试
cmd /c“你的命令”
Try
cmd /c "your command"
您可以使用 Windows 任务计划程序命令行界面“schtasks /run”来启动运行“another_prog”的作业吗?你必须提前创建工作。 Windows (NT) 资源工具包中还曾经有一个“SOON”程序,该程序将为“AT”命令调度程序创建动态条目,以便在几分钟内运行作业,而无需提前设置作业,稍微搜索一下还是可以找到的。
Could you use the windows task scheduler command line interface "schtasks /run" to start a job that runs the "another_prog"? You'd have to create the job ahead of time. There also used to be a "SOON" program with the Windows (NT) Resource Kit that would create dynamic entries for the "AT" command scheduler to run a job in a few minutes that would not require setting up a job ahead of time, it can still be found with a little searching.
您可以创建一个混合批处理/JScript 文件(即能够运行嵌入式 JScript 的批处理文件),其中 JScript 部分将使用 shell.Run(prog, 0, false):
You can create a hybrid batch/JScript file (i.e. a batch file able to run embedded JScript) where the JScript part will run another_prog in detached mode with shell.Run(prog, 0, false):