Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


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

01 Jun 2014   #1
bumblebur

windows 7
 
 
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 System SpecsSystem Spec
.
01 Jun 2014   #2
DavidE

Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64
 
 

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 System SpecsSystem Spec
01 Jun 2014   #3
BrightBlessings

Win7 Pro-64 Bit
 
 

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 System SpecsSystem Spec
.

01 Jun 2014   #4
bumblebur

windows 7
 
 

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 System SpecsSystem Spec
01 Jun 2014   #5
dperecky

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

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 System SpecsSystem Spec
01 Jun 2014   #6
bumblebur

windows 7
 
 

Quote   Quote: Originally Posted by dperecky View Post
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 System SpecsSystem Spec
01 Jun 2014   #7
dperecky

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

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 System SpecsSystem Spec
01 Jun 2014   #8
strollin

W10 Pro desktop, W10 laptop, W10 laptop, W10 Pro tablet (all 64-bit)
 
 

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 System SpecsSystem Spec
01 Jun 2014   #9
Ztruker

Windows 10 Pro X64
 
 

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

Quote:
@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 System SpecsSystem Spec
02 Jun 2014   #10
bumblebur

windows 7
 
 

Quote   Quote: Originally Posted by Ztruker View Post
Add %* after the call to VLC. That will pass all parameters given to the bat fil onto VLC>

Quote:
@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 System SpecsSystem Spec
Reply

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




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Serial read/write in batch file?
Hello all. I'm trying to write a request to COM2 and capture the answer. My device is 19200 baud 8/1 non parity. Using a freeware terminal called termite I can send the hex instruction and receive the answer, as verified in HHD serial monitor. My batch file looks like this: MODE COM2:...
General Discussion
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
How do I write batch file to delete thousands of files
Was infected by the matsnu1 virus recently which encrypes and locks all your data files. Got all my files back by running matsnu1decryp.exe You need an original clean file before the virus struck for it to work out how to decrypt all your other files does does save the day. Down side is that you...
Software
batch file open file for program in the startup folder
I have a computer that is a drone specifically for an outside LED sign. This computer is designed to never shut off and doesn't have any other program on it besides Operating System and the sign software. I need to create a batch file that I can place in the "start-up" folder that will open the...
General Discussion
I want to write a batch file to get the DNS numbers behind a router.
I do a lot of internet troubleshooting and would like to put a simple batch file in customers computers that will let me see their DNS numbers when they are using a router. I currently do this from a command prompt for Comast: nslookup set type=ns comcast.net It's been years since I...
Network & Sharing


Our Sites

Site Links

About Us

Find 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 05:13.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App