简体   繁体   English

关闭批处理文件时执行命令

[英]Executing a command when closing Batch file

I have a batch file playing a sound in the background while it runs, using the method at Batch file executing a sound silently however, when I exit the batch file, the music will continue to play. 我有一个批处理文件,它在运行时在后台播放声音,使用批处理文件中的方法以无声方式执行声音,但是,当我退出该批处理文件时,音乐将继续播放。

Id there any way to run a command while a batch file is closing, so that the sound file will stop playing? 批处理文件关闭时,是否有任何方法可以运行命令,以便声音文件停止播放?

I've tried an example I found called onexit: 我尝试了一个我发现的名为onexit的示例:

onexit taskkill /im wmplayer.exe

But it doesn't work. 但这是行不通的。

Just : 只是:

taskkill /f /im wmplayer.exe

Should work. 应该管用。

First idea i had is another batch: 我的第一个想法是另一批:

@ECHO OFF
START "" /W <YourBatchhere>
TASKKILL /im "wmplayer.exe"

should do the job :) 应该做的工作:)

The /W will wait at that point, still YourBatchhere has ended. /W将在此时等待,但YourBatchhere仍已结束。 Regardless of success or error. 不管成功或失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM