How can I write a batch file that opens a file in a program?

Page 1 of 2 12 LastLast

  1. Posts : 4
    windows 7
       #1

    How can I write a batch file that opens a file in a program?


    I wrote this batch file which does what I want it to do so far.

    Code:
    @echo off
    
    "C:\Users\xxxxxx\Documents\HideTaskbar\HideTaskbar.exe"
    "C:\Program Files (x86)\VideoLANold\VLC\vlc.exe"
    "C:\Users\xxxxxx\Documents\HideTaskbar\ShowTaskbar.exe"
    
    exit
    VLC is a video program so I want to associate video files to this bat file. This would mean that when i clicked on a video file in Windows Explorer, the bat file would execute and VLC would open the file I double clicked. At the moment the only thing that happens in this setup is that the bat file executes like normal but no video is played.

    Is this possible, and if so how can I accomplish it?
      My Computer


  2. Posts : 6,330
    Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64 +Linux_VMs +Chromium_VM
       #2

    Have you tried associating the video files to open with VLC by default ?
    Maybe you don't need a BAT file ?

    Default Programs - Associate a File Type or Protocol
      My Computer


  3. Posts : 1,491
    Win7 Pro-64 Bit
       #3

    Why not just associate the vide files to open in VLC using default.
    Default Programs - Associate a File Type or Protocol

    David said the same before I did.
      My Computer


  4. Posts : 4
    windows 7
    Thread Starter
       #4

    I've had VLC associated with these files for a long time but now I need some added functionality.

    I want the other two programs to run as well

    The hidetaskbar program runs at the same time as vlc in this batch file and then when i close vlc the last program runs which is perfect. The only issue right now is that when I associate a video file with the batch file, it doesn't pass this file to VLC which means that VLC opens but the selected file doesn't start playing.
      My Computer


  5. Posts : 83
    win7 64bit Ult. using: XP Mode, in English or Español, SUA, Bitlocker
       #5

    Old school method:
    call "C:\Users\xxxxxx\Documents\HideTaskbar\HideTaskbar.exe"
    call "C:\Program Files (x86)\VideoLANold\VLC\vlc.exe"
    call "C:\Users\xxxxxx\Documents\HideTaskbar\ShowTaskbar.exe"
      My Computer


  6. Posts : 4
    windows 7
    Thread Starter
       #6

    dperecky said:
    Old school method:
    call "C:\Users\xxxxxx\Documents\HideTaskbar\HideTaskbar.exe"
    call "C:\Program Files (x86)\VideoLANold\VLC\vlc.exe"
    call "C:\Users\xxxxxx\Documents\HideTaskbar\ShowTaskbar.exe"
    I've given this a shot. It doesn't solve the issue unfortunately. When I go into Windows Explorer, associate the video files with the bat file and click it... it opens up all three programs in order but vlc doesn't play the file.
      My Computer


  7. Posts : 83
    win7 64bit Ult. using: XP Mode, in English or Español, SUA, Bitlocker
       #7

    It does what it's supposed to- start up Vlc.exe.

    I'm not sure, but if you're trying to make vlc.exe do something, try putting a filename after it, with a one space separator after vlc.exe.

    It's not really the way to do it these days, as there are playlists for this purpose... But if you want to, you can specify one file on a line as described. This is called hardcoding.

    Then you can make for example 10 vlc.exe lines, with 1 different video/music file after each one (complete with it's full folder path). This is possible, and it will work. It's a bit cumbersome. You probably want to figure out how you can make a playlist instead....
      My Computer


  8. Posts : 4,287
    W10 Pro desktop, W11 laptop, W11 Pro tablet (all 64-bit)
       #8

    Instead of mucking with hiding/unhiding the taskbar when you start VLC, why don't you just change the settings in VLC to start fullscreen? This will automatically hide the taskbar when running VLC and automatically restore it when exited.

      My Computer


  9. Posts : 6,285
    Windows 10 Pro X64
       #9

    Add %* after the call to VLC. That will pass all parameters given to the bat fil onto VLC>

    @echo off
    "C:\Users\xxxxxx\Documents\HideTaskbar\HideTaskbar.exe"
    "C:\Program Files (x86)\VideoLANold\VLC\vlc.exe" %*
    "C:\Users\xxxxxx\Documents\HideTaskbar\ShowTaskbar.exe"
    exit
      My Computer


  10. Posts : 4
    windows 7
    Thread Starter
       #10

    Ztruker said:
    Add %* after the call to VLC. That will pass all parameters given to the bat fil onto VLC>

    @echo off
    "C:\Users\xxxxxx\Documents\HideTaskbar\HideTaskbar.exe"
    "C:\Program Files (x86)\VideoLANold\VLC\vlc.exe" %*
    "C:\Users\xxxxxx\Documents\HideTaskbar\ShowTaskbar.exe"
    exit
    Wow this is nearly perfect. Thank you sir! The only thing off is that while the video is playing, a cmd.exe command window stays open and then closes when I close VLC. It'd be nice if that cmd window closed before VLC opened.
      My Computer


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 01:12.
Find Us