pass parameters to batch file via File URI in Windows

Using Windows 10 here.

Code in open_video.bat

"%USERPROFILE%\Desktop\VLCPortable media player\VLCPortable.exe" --start-time=54 --stop-time=89 "%USERPROFILE%\Downloads\some_video.mkv"

Location of open_video.bat is C:

in Notepad++ I have this link below and I call the batch file by double-clicking on it:

file:///C:\open_video.bat

When I double-click the batch file, it opens some_video.mkv in VLC starting at the 54 second mark, plays it up to the 89 second mark, and then loops the video between those two timestamps.

However, I don't want to hard code 54 and 89. Is there any way I can write the link to the batch file, and modify the code in the batch file such that I can pass 54 or whatever and 89 or whatever as a parameter or argument?

E.g., re-write the link to the batch file to something like:

file:///C:\open_video.bat?start=54&end=89

and modify the batch file's code like so:

"%USERPROFILE%\Desktop\VLCPortable media player\VLCPortable.exe" --start-time=start --stop-time=end "%USERPROFILE%\Downloads\some_video.mkv"

or some such?

0

1 Answer

You can modify the batch file like this:

"%USERPROFILE%\Desktop\VLCPortable media player\VLCPortable.exe" --start-time=%1 --stop-time=%2 "%USERPROFILE%\Downloads\some_video.mkv"

Then call it like:

C:\open_video.bat 54 89

Or in file URI:

file:///C:\open_video.bat%2054%2089

In encoded URL %20 is space and replace 54 and 89 with parameters.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like