View Full Version : Problem with dos exe closing

07-27-2010, 05:12 PM
I have a file type that opens with a dos exe that closes when done. I need to keep the window open so I can read the output. I'm using Win7.

I've tried to associate the file type to a batch file with a pause command, but the file name isn't passed on to the exe.

Any ideas?

07-27-2010, 05:40 PM
Put the call to the program in a batch file, along with the pause command:

@echo off
your_command.exe %*

and call the batch file with the command line arguments you want to pass to the EXE.

For more info on using command line parameters in a batch file, here's one site with info:

07-27-2010, 06:07 PM
The only parameter I need to pass on is a file name that is always changing and in different places.


-double click 1.jpg in windows explorer
-jpg's are set to open with jpgopener.bat

@echo off

In this case 1.jpg isn't passed onto jpgopener.bat and therefore not passed onto jpgopener.exe

I could add the jpg's location to the .bat with a command line argument(as you suggest):

@echo off
jpgopener.exe %1

But I would have to get the location of the jpg and pass it on to the .bat every time. Multiple files, multiple locations. Very tedious.

Dr. Death
07-28-2010, 05:27 AM
Put the batch file (or a shortcut to it) in the "Send To..." folder (c:\documents and settings\<username>\SendTo.) You may need admin privileges to access this folder in Vista/Win 7.

Then just right click your file, and select "Send to..." and pick your batch file. The %1 argument will contain the file name you "sent" to the batch file (more properly termed 'command' files in NT/XP/Vista etc.)

[EDIT] In Win7, the SendTo folder is in c:\users\<username>\AppData\Roaming\Microsoft\Windows\

07-28-2010, 04:48 PM
Thank you, that works. But it didn't stop the closing window problem.

After a lot of trial and error I got this to work:

cmd /k "C:\Program Files\program.exe" -a %1