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
I'd use /T
switch (Tree kill): terminates the specified process and any child processes which were started by it.
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
)
Note taskkill
command is echoed merely... Remove echo
when debugged.
This work for me, and is only one line.
Taskkill /IM "wscript.exe" /F>nul 2>&1