音乐停止播放后在后台PC [英] Stop Music Once Playing In Background PC

查看:216
本文介绍了音乐停止播放后在后台PC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我试图让一首歌在窗口的后台播放,过了一小的样子,我发现这一点:

Hello I am trying to get a song to play in the background of windows, after a little looking I found this:

@echo off
set file=RRLJ.mp3
(  echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
   echo Sound.URL = "%file%"
   echo Sound.Controls.play
   echo do while Sound.currentmedia.duration = 0
   echo wscript.sleep 100
   echo loop
   echo wscript.sleep (int(Sound.currentmedia.duration^)+1^)*1000) >sound.vbs
start /min sound.vbs

这非常适用于启动首歌,但我没有从停止它的.bat 文件的方式。我发现把它剪短的唯一方法是打开任务管理器,在进程关闭它。可能有人请告诉我如何将其关闭或是否有这样做的更好的办法?

This works well for starting the song but I have no way of stopping it from a .bat file. The only way I found to cut it short is to open task manager and close it from the processes. Could someone please tell me how to close it or if there is a better way of doing this?

我曾尝试:

taskkill /im wscript.exe

不过,我不断收到窗口说着什么:
成功:发送终止sidnal到进程的wscript.exe有PID 185448
但音乐继续播放,直到我手动任务管理器结束它

But I keep getting something in the window saying: SUCCESS: Sent termination sidnal to the process "wscript.exe" with PID 185448 but the music continues to play until I manually end it with task manager

推荐答案

我会使用 / T 开关(树杀):终止指定的进程和任何子进程这是由它开始。

I'd use /T switch (Tree kill): terminates the specified process and any child processes which were started by it.

下面是一个脚本找到的ProcessID 终止究竟需要过程只用 PID

Here is a script to find ProcessID to terminate exactly needed process only using PID:

@ECHO OFF >NUL
for /F "usebackq tokens=*" %%G in (
      `wmic process where "CommandLine like '%%sound.vbs%%' AND Caption like '%%script.exe%%'" get ProcessID/value ^|find /I "="`
    ) do (
        rem echo %%G
        for /F "tokens=2 delims==" %%H in ("%%~G") do echo  taskkill /T /F /PID %%H  
    )

请注意 TASKKILL 命令只回荡...删除回声调试时。

Note taskkill command is echoed merely... Remove echo when debugged.

这篇关于音乐停止播放后在后台PC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆