Annoyances.org
Home » Windows Me Discussion Forum » Message 1252105256 » Entire Thread Search | Help | Home
  
"Open With" Command Line Switches
Showing all messages in thread #1252105256
Windows Me Annoyances Discussion Forum


The following are all of the messages in this thread (7 in all), shown in chronological order. Click any message subject to view that message by itself or to view the thread hierarchy.
"Open With" Command Line Switches
Friday, September 4, 2009 at 4:00 pm
Posted by madman420 (15 messages posted)

OS: Windows ME

PROBLEM: The "Open With..." dialog doesn't allow me to add command line switches 
after the program I choose.

EXAMPLE: I want my .BAS files to automatically open *and run* with 
"D:\QBASIC.EXE /RUN file.bas" when I double-click them.

SO FAR...: I can (obviously) associate the .BAS files with QBASIC.EXE, but I can't 
figure out how to pass the '/run' flag to the command.

[Reply or follow-up to this message]

Tip: Run a free scan for common Windows errors ad

re: "Open With" Command Line Switches
Friday, September 4, 2009 at 5:16 pm
Posted by Keith Stanier (1655 messages posted)

madman420 wrote:
|PROBLEM: The "Open With..." dialog doesn't allow me to add command line switches 
|after the program I choose.

|EXAMPLE: I want my .BAS files to automatically open *and run* with 
|"D:\QBASIC.EXE /RUN file.bas" when I double-click them.

|SO FAR...: I can (obviously) associate the .BAS files with QBASIC.EXE, but I can't 
|figure out how to pass the '/run' flag to the command.

Well it works for me madman. I've just added a switch to my Qbasic C:\WINDOWS\QBASIC.EXE 
c:\projects\Train.bas an it open Qbasic with that bas file.

Forget the /run bit just add the location of the bas file.

[Reply or follow-up to this message]

re: "Open With" Command Line Switches
Saturday, September 5, 2009 at 1:14 am
Posted by madman420 (15 messages posted)

>Well it works for me madman. I've just added a switch to my Qbasic C:\WINDOWS\QBASIC.EXE
>c:\projects\Train.bas
an it open Qbasic with that bas file.
>
>Forget the /run bit just add the location of the bas file. I can double-click & open files in QBasic, no problem. I just want to have the option to use the /run switch to automatically run them. Command line switches can be important for other programs as well. (don't forget that I am running Windows ME, it supposedly dumbed-up the associated programs thing) I'm thinking, however, since I won't always want to run every QBasic .bas file, I might just add a right-click context ("Open in QBasic" or "Run from QBasic") menu option for .BAS files in the registry. It would probably be easier anyway.

[Reply or follow-up to this message]

re: "Open With" Command Line Switches
Saturday, September 5, 2009 at 3:02 am
Posted by Keith Stanier (1655 messages posted)

madman420 wrote:
|Forget the /run bit just add the location of the bas file.

|I can double-click & open files in QBasic, no problem.  I just want to have the
|option to use the /run switch to automatically run them.  Command line switches
|can be important 
|for other programs as well.  (don't forget that I am running Windows ME, it supposedly 
|dumbed-up the associated programs thing)

Well I've never used the RUN switch so I've just had a read of the help. Now I'm 
not sure how this works as it shows.

RUN [{linenumber | file$}]
If no linenumber is given then the first executable line is used.

RUN c:\dos\test.bas

But this doesn't work for me and they also talk about the CHAIN function.

Do you have the QBASIC.HLP?

[Reply or follow-up to this message]

re: "Open With" Command Line Switches
Saturday, September 5, 2009 at 3:05 pm
Posted by madman420 (15 messages posted)

Whoa buddy . . .
Your talking about the RUN Keyword *inside the QBasic programming language*, not 
the (Dos) command line switch /run.  And you need to put double quotes (") around 
the path and filename to solve *your* problem.

I'm also thinking (in addition to explorer shell extensions) that a batch file might 
be a way to go. (for my situation)

[Reply or follow-up to this message]

re: "Open With" Command Line Switches
Monday, September 7, 2009 at 8:31 pm
Posted by madman420 (15 messages posted)

Well the "Open With" feature and File Type handling in Windows ME (4.90.3000) sucks. It turns out that it's actually easier to just hand-hack the registry than it is to use any other interface that Microsoft provides.

Anyway, here is a nifty solution I came up with:

1) Find the associated program in:
HKEY_CLASSES_ROOT\Applications\
qbasic.exe in my case. It may help to actually try to associate the application the normal way first (shift-right-click file, Open With -> Choose Program, browse for app, select always use this program...).

2) If you already associated the program w/ the file then there should be a "shell\open\command" branch beneath it. If not, create it (right-click -> New -> Key). Now, in the "Default" value of the "command" key, place the command to run when you select your file by double-clicking or right-click ->Open:
d:\qbasic\qbasic.exe /h %1

You should try putting the %1 inside of double-quotes like this: "%1" ...that will help your app open files and paths with spaces in them. However, with my old 16-bit MS-DOS app, it doesn't understand long filenames anyway. If you're just trying to get /command /line /switches to work, skip steps 3) and 4), you're done.

3) Do the same thing as for "open", but now use an option (aka: verb) like "run". So create this key:
HKEY_CLASSES_ROOT\Applications\qbasic.exe\shell\Run\command

4) Add this to the "Default" value in the "Run" (or whatever you called it) key:
d:\qbasic\qbasic.exe /h /run %1

Following the same rules as with the "open\command" above. This adds another option ("Run") to the right-click menu for the file.

The above stuff makes my context (aka: shortcut) menu give me both an "Open" and a "Run" choice when I right-click a .BAS file in my win9x system:
right-click -> view 
image

With both the "Open" and "Run" scenarios above, Windows will use the name of the registry key itself, or you can change the default value of the key to something like: RUN IT RIGHT NOW!! ...but it's probably best to leave the actual registry key's name simple - like 'open' or 'run' (without quotes).

HERE IS A .REG FILE TO DO THE WHOLE THING FOR YOU:


REGEDIT4

[HKEY_CLASSES_ROOT\Applications\qbasic.exe]

[HKEY_CLASSES_ROOT\Applications\qbasic.exe\shell]
@="open"

[HKEY_CLASSES_ROOT\Applications\qbasic.exe\shell\open]

[HKEY_CLASSES_ROOT\Applications\qbasic.exe\shell\open\command]
@="d:\\qbasic\\qbasic.exe /h %1"

[HKEY_CLASSES_ROOT\Applications\qbasic.exe\shell\run]
@="Run"

[HKEY_CLASSES_ROOT\Applications\qbasic.exe\shell\run\command]
@="d:\\qbasic\\qbasic.exe /h /run %1"

[Reply or follow-up to this message]

re: "Open With" Command Line Switches
Monday, September 7, 2009 at 9:55 pm
Posted by madman420 (15 messages posted)

shoot...!

step 4) should've read:

Add this to the "Default" value in the "Run\command" (or whatever you called it) key:
d:\qbasic\qbasic.exe /h /run %1

here is a link to a picture of the menu in action (also broken in previous message)

[Reply or follow-up to this message]

Tip: Use one of the [Reply or follow-up to this message] links above to add a message to this thread
Return to the Windows Me Discussion Forum


All content at Annoyances.org is Copyright ©1995-2012 Creative Elementtm All rights reserved.
Please do not plagiarize; redistributing these pages without permission is strictly prohibited.