running a batch file without the .bat extension?

M

McBob

Shorter version of question: I want to be able to take a plain ol'
batch file (something.bat) and change the extension (something.foo),
and still have it run like a batch file. I've tried the following app
associations for .foo:

cmd.exe "%1"
command.com "%1"
cmd.exe < "%1"
command.com < "%1"
"%1" %*

The first four simply open a command prompt but don't parse the batch
file, and the last one gives me the "something.foo is not a valid
Win32 application" error. I've also tried making .foo of type batfile,
using the following registry entry:

[HKEY_CLASSES_ROOT\.yoo]
@="batfile"

This also gives the invalid Win32 app error. When I rename it back to
..bat, there are no problems. What must I do to get this to work?

Longer version of question: I want to change some things in the
registry when a client machine clicks a link on a webpage. Batch files
are the easiest way to do this, but then you get the 'Open or Save?'
dialog, which I want to avoid. Since you can't disable this for batch
files (and it would be a terrible thing to do anyway), I figure I can
have a different extension that functions as a batch file, but allows
to use the "Always do this action" checkbox. I can then set the client
machines in advance so that that checkbox is already ticked, and when
they eventually go the page and click the link to something.foo, it
will run automaticly and alter the registry. I can't seem to think of
any other way to accomplish this goal, except for using an ActiveX
control to launch the batch file. But I don't have very good
programming skills, and the only pre-made control I know of
(IntraLaunch by Particle Software) costs money, so I'd like to find
another way. Other than my renamed-batch-file solution, how could I
accomplish this?

Thank you very much!
 
D

David Candy

Maybe this could work. Maybe pathext (type in help) can help
Programs and documents can be added to the registry so typing their name without their path in the Start - Run dialog box or shortcut enables Windows to find them.

This is a generic reg file. Copy the lines below to a new Text Document and save it as anyname.reg. Edit it with your programs or documents.


In paths use \\ to seperate folder names in key paths as regedit uses a single \ to seperate it's key names. All reg files start with REGEDIT4. A semicolon turns a line into a comment. The @ symbol means to assign the value to the key rather than a named value.

The file doesn't have to exist. This can be used to set Word.exe to open Winword.exe.

This sample add IE.Txt (from IE5) to the registry so typing IE.Txt will open it. I think the file is called IE4.txt in IE4.

REGEDIT4
;The bolded name below is the name of the document or program, <filename>.<file extension>

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\IE.txt]

;The @ means the path to the file is assigned to the default value for the key.
;The whole path in enclosed in a quotation mark ".

@="\"C:\\Program Files\\Internet Explorer\\IE.txt\""

;Optional Parameters. The semicolon means don't process the line. Remove it if you want to put it in the registry

;Informs the shell that the program accepts URLs.

;"useURL"="1"

;Sets the path that a program will use as its' default directory. This is commented out.

;"Path"="C:\\Program Files\\Microsoft Office\\Office\\"

--
----------------------------------------------------------
http://home.comcast.net/~wizardofwhimsy/index.html
McBob said:
Shorter version of question: I want to be able to take a plain ol'
batch file (something.bat) and change the extension (something.foo),
and still have it run like a batch file. I've tried the following app
associations for .foo:

cmd.exe "%1"
command.com "%1"
cmd.exe < "%1"
command.com < "%1"
"%1" %*

The first four simply open a command prompt but don't parse the batch
file, and the last one gives me the "something.foo is not a valid
Win32 application" error. I've also tried making .foo of type batfile,
using the following registry entry:

[HKEY_CLASSES_ROOT\.yoo]
@="batfile"

This also gives the invalid Win32 app error. When I rename it back to
.bat, there are no problems. What must I do to get this to work?

Longer version of question: I want to change some things in the
registry when a client machine clicks a link on a webpage. Batch files
are the easiest way to do this, but then you get the 'Open or Save?'
dialog, which I want to avoid. Since you can't disable this for batch
files (and it would be a terrible thing to do anyway), I figure I can
have a different extension that functions as a batch file, but allows
to use the "Always do this action" checkbox. I can then set the client
machines in advance so that that checkbox is already ticked, and when
they eventually go the page and click the link to something.foo, it
will run automaticly and alter the registry. I can't seem to think of
any other way to accomplish this goal, except for using an ActiveX
control to launch the batch file. But I don't have very good
programming skills, and the only pre-made control I know of
(IntraLaunch by Particle Software) costs money, so I'd like to find
another way. Other than my renamed-batch-file solution, how could I
accomplish this?

Thank you very much!
 
M

McBob

I'm not sure I understand how this would solve my problem. I don't
want to type one thing into 'Run' and have another thing come up. I
want to properly register the .foo extension to run the same way .bat
files run, so that I can have clients on my intranet automaticly run
these renamed batch files from a webpage link. The only reason for
renaming it to .foo is so that I can set the clients' Internet
Explorers to automaticly run these, which if i did for .bat files
would be a serious security hole.

David Candy said:
Maybe this could work. Maybe pathext (type in help) can help
Programs and documents can be added to the registry so typing their name
without their path in the Start - Run dialog box or shortcut enables
Windows to find them.

This is a generic reg file. Copy the lines below to a new Text Document
and save it as anyname.reg. Edit it with your programs or documents.


In paths use \\ to seperate folder names in key paths as regedit uses a
single \ to seperate it's key names. All reg files start with REGEDIT4.
A semicolon turns a line into a comment. The @ symbol means to assign
the value to the key rather than a named value.

The file doesn't have to exist. This can be used to set Word.exe to open
Winword.exe.

This sample add IE.Txt (from IE5) to the registry so typing IE.Txt will
open it. I think the file is called IE4.txt in IE4.

REGEDIT4
;The bolded name below is the name of the document or program,
<filename>.<file extension>

[HKEY LOCAL MACHINE\Software\Microsoft\Windows\CurrentVersion\App
Paths\IE.txt]

;The @ means the path to the file is assigned to the default value for
the key.
;The whole path in enclosed in a quotation mark ".

@="\"C:\\Program Files\\Internet Explorer\\IE.txt\""

;Optional Parameters. The semicolon means don't process the line. Remove
it if you want to put it in the registry

;Informs the shell that the program accepts URLs.

;"useURL"="1"

;Sets the path that a program will use as its' default directory. This
is commented out.

;"Path"="C:\\Program Files\\Microsoft Office\\Office\\"

--
----------------------------------------------------------
http://home.comcast.net/~wizardofwhimsy/index.html
McBob said:
Shorter version of question: I want to be able to take a plain ol'
batch file (something.bat) and change the extension (something.foo),
and still have it run like a batch file. I've tried the following app
associations for .foo:

cmd.exe "%1"
command.com "%1"
cmd.exe < "%1"
command.com < "%1"
"%1" %*

The first four simply open a command prompt but don't parse the batch
file, and the last one gives me the "something.foo is not a valid
Win32 application" error. I've also tried making .foo of type batfile,
using the following registry entry:

[HKEY CLASSES ROOT\.yoo]
@="batfile"

This also gives the invalid Win32 app error. When I rename it back to
.bat, there are no problems. What must I do to get this to work?

Longer version of question: I want to change some things in the
registry when a client machine clicks a link on a webpage. Batch files
are the easiest way to do this, but then you get the 'Open or Save?'
dialog, which I want to avoid. Since you can't disable this for batch
files (and it would be a terrible thing to do anyway), I figure I can
have a different extension that functions as a batch file, but allows
to use the "Always do this action" checkbox. I can then set the client
machines in advance so that that checkbox is already ticked, and when
they eventually go the page and click the link to something.foo, it
will run automaticly and alter the registry. I can't seem to think of
any other way to accomplish this goal, except for using an ActiveX
control to launch the batch file. But I don't have very good
programming skills, and the only pre-made control I know of
(IntraLaunch by Particle Software) costs money, so I'd like to find
another way. Other than my renamed-batch-file solution, how could I
accomplish this?

Thank you very much!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top