简体   繁体   English

CMD命令未在批处理文件中运行

[英]CMD command not running in batch file

I am trying to create a batch file that runs a command. 我正在尝试创建一个运行命令的批处理文件。

The first part of the command checks to see if a particularly named window is open on my desktop. 命令的第一部分检查是否在我的桌面上打开了一个特别命名的窗口。 If it is it then closes that window (by sending a command to the program with the window open - Virtual Audio Cable). 如果是,则关闭该窗口(通过在窗口打开的情况下向程序发送命令-虚拟音频电缆)。

@For /f "Delims=:" %A in ('tasklist /nh /v /fi "WINDOWTITLE eq Headphones"') do @if %A==INFO (echo Prog not running) else (start /min "audiorepeater_ks" "c:program files\Virtual Audio Cable\audiorepeater_ks.exe" /CloseInstance: Headphones)

Now this command seems to work fine when I execute it via the command line. 现在,当我通过命令行执行该命令时,它似乎可以正常工作。

But it does nothing when I try to put it in a batch file 但是当我尝试将其放入批处理文件中时它什么也没做

I have tried a .bat file and a .cmd file and also created a shortcut to the .cmd file where i have prepended the target field in properties with "C:\\Windows\\System32\\cmd.exe /c" 我尝试了.bat文件和.cmd文件,还创建了.cmd文件的快捷方式,在该快捷方式中,我在属性中的目标字段前面添加了"C:\\Windows\\System32\\cmd.exe /c"

Any ideas on how I can get this to run via batch? 关于如何让它通过批处理运行的任何想法?

Try This : 尝试这个 :

@echo off
For /f "Delims=:" %%A in ('tasklist /nh /v /fi "WINDOWTITLE eq Headphones"') do (if "%%A"=="INFO" (
echo Prog not running
) else (
start /min "audiorepeater_ks" "%ProgramFiles%\Virtual Audio Cable\audiorepeater_ks.exe" /CloseInstance: Headphones))
pause>nul

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

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