BAT START w/ command recognized

谁都会走 提交于 2019-12-25 04:26:29

问题


My ultimate goal is:

  • Drag & Drop video selection onto batch file
  • VLC runs with selection as the playlist and closes at the end
  • GlovePIE loads simultaneously and runs the script
  • Computer shuts down when VLC closes
  • User can cancel the shutdown with one key (two is fine)

I tried to put this together but it fails miserably... The GlovePIE syntax does not work with a START operation, but I do not know of another way to run both programs at the same time. I tried making a bat that runs VLC.bat and GlovePIE.bat but I don't know how to pass variables between the Launcher.bat and VLC.bat. Anyways, having it all as a single bat seems like a better idea to me...


What I have so far:

@echo off
if exist "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" (
start "" "C:\Program Files\GlovePIE045Free\piefree.exe" -"C:\Program Files\GlovePIE045Free\CustomScripts\xbox360VLCremote.PIE" /tray
start /wait "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 vlc://quit
) else (goto :EOF)
taskkill /f /im piefree.exe
cls
choice /c CP /D P /T 120 /M "Waiting for 120 seconds: Press C to cancel shutdown, or P to power off now"
if errorlevel 2 shutdown -s

This is loading GlovePIE properly but multiple video's are not being noticed.


回答1:


I can't test this, but I'd try

start /wait "" "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" %* vlc://quit

Note: extra pair of quotes. This sets the title of the STARTed session, otherwise the first "quoted string" is used.

%* means allcommand-line arguments. %10 is invalid, only %1..%9 are available. %10 would be interpreted as %1 with 0 appended.


Further thought: If it fails when placed in a block (parenthesised sequence of statements) then clasically, restructure the code, but you could try

for /f "delims=" %%z in ("%*") do start /wait "" "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" %%z vlc://quit

(theory : there are ) in the parameters being passed)




回答2:


This is the completed and working code. Thanks everyone for the help.

@echo off
if exist "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" (
start "" "C:\Program Files\GlovePIE045Free\piefree.exe" -"C:\Program Files\GlovePIE045Free\CustomScripts\xbox360VLCremote.PIE" /tray
start /wait "" "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" %* vlc://quit
) else (goto :EOF)
taskkill /f /im piefree.exe
cls
choice /c CP /D P /T 120 /M "Waiting for 120 seconds: Press C to cancel shutdown, or P to power off now"
if errorlevel 2 shutdown -s


来源:https://stackoverflow.com/questions/21151408/bat-start-w-command-recognized

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!