Reputation: 11
My batch file fails to implement the call command when passed a file (.mkv), but works when ran directly with no parameters. The commands after work including running vlc with arguments.
call "C:\Users\****\Desktop\System Tools\Monitors\Primary2.bat"
start "VLC media player.lnk" %1
running on windows 7 if that matters.
update: It seems that the call function does not want to work with primary2.bat, but will work with a much simpler batch file that does one of the things primary2.bat does
for comparison primary2.bat
@ECHO off
IF Exist Single.txt (
IF EXIST Primary1.txt (
echo Primary Screen Set to Two >> Primary2.txt
del /q Primary1.txt
echo Triple Monitors enabled >> Triple.txt
del /q Single.txt
If Exist HDMI.txt (
"C:\Users\****\Desktop\System Tools\Monitors\TripleHDMI\TripleHDMI Primary2.lnk"
)
IF Exist VGA.txt (
"C:\Users\****\Desktop\System Tools\Monitors\TripleVGA\TripleVGA Primary2.lnk"
)
)
)
IF Exist Dual.txt (
IF EXIST Primary1.txt (
echo Primary Screen Set to Two >> Primary2.txt
del /q Primary1.txt
echo Triple Monitors enabled >> Triple.txt
del /q Dual.txt
If Exist HDMI.txt (
"C:\Users\****\Desktop\System Tools\Monitors\TripleHDMI\TripleHDMI Primary2.lnk"
)
IF Exist VGA.txt (
"C:\Users\****\Desktop\System Tools\Monitors\TripleVGA\TripleVGA Primary2.lnk"
)
)
IF EXIST Primary3.txt (
echo Primary Screen Set to Two >> Primary2.txt
del /q Primary3.txt
echo Triple Monitors enabled >> Triple.txt
del /q Dual.txt
If Exist HDMI.txt (
"C:\Users\****\Desktop\System Tools\Monitors\TripleHDMI\TripleHDMI Primary2.lnk"
)
IF Exist VGA.txt (
"C:\Users\****\Desktop\System Tools\Monitors\TripleVGA\TripleVGA Primary2.lnk"
)
)
)
IF Exist Triple.txt (
IF EXIST Primary1.txt (
echo Primary Screen Set to Two >> Primary2.txt
del /q Primary1.txt
If Exist HDMI.txt (
"C:\Users\****\Desktop\System Tools\Monitors\TripleHDMI\TripleHDMI Primary2.lnk"
)
IF Exist VGA.txt (
"C:\Users\****\Desktop\System Tools\Monitors\TripleVGA\TripleVGA Primary2.lnk"
)
)
IF EXIST Primary3.txt (
echo Primary Screen Set to Two >> Primary2.txt
del /q Primary3.txt
If Exist HDMI.txt (
"C:\Users\****\Desktop\System Tools\Monitors\TripleHDMI\TripleHDMI Primary2.lnk"
)
IF Exist VGA.txt (
"C:\Users\****\Desktop\System Tools\Monitors\TripleVGA\TripleVGA Primary2.lnk"
)
)
)
hello.bat used it to test, this one works
echo hello
"C:\Users\****\Desktop\System Tools\Monitors\TripleHDMI\TripleHDMI Primary2.lnk"
)
pause
both work individually
Upvotes: 1
Views: 152
Reputation: 11
Figured out my problem. There were references to local files in the external batch file, changed them all to full addresses and now it works flawlessly.
changed HDMI.txt to "C:\Users****\Desktop\System Tools\Monitors\HDMI.txt" and so on for all addresses.
For some reason batch files that get called from cmd can't use relative addresses
Upvotes: 0
Reputation: 31251
If all you are trying to do is pass the mkv
file as a parameter to the batch file you are calling then the syntax is
call "C:\Users\****\Desktop\System Tools\Monitors\Primary2.bat" mkvfile.mkv
Then in the calling batch file the mkv
file will be accessible using %1
.
Upvotes: 1