PDA

View Full Version : Problem with dos exe closing



=A!M=OakWind
07-27-2010, 04: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?

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


@echo off
your_command.exe %*
pause

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:
http://stackoverflow.com/questions/26551/how-to-pass-command-line-parameters-in-batch-file

=A!M=OakWind
07-27-2010, 05:07 PM
The only parameter I need to pass on is a file name that is always changing and in different places.

Example:

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


@echo off
jpgopener.exe
pause

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
pause

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, 04: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\

=A!M=OakWind
07-28-2010, 03: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