.bat not defined; can't add it

R

Richard

I wrote a .bat script SayHello.bat amd got (essentially): "C:
\SayHello.bat is not a valid Win32 application."

The two line script was simply:
@echo Hello
@pause

To my surprise, "Windows Explorer | Tools | Folder options | File
types" reported consecutively: AWB, B64, BHX ... but no BAT.

I attempted to add BAT by clicking New, providing the extension
"BAT" (without the quotes), and clicking Advanced. In a moment, the
Associated File Type :MS-DOS Batch File" was reported. I clicked OK.
and Close. But I got the same symptom!

I checked to see whether BAT had, in fact, been added to XP's
registered types. It reported the same trio as shown above; no BAT.

I'm running WinXP/SP2, which is up-to-date with Windows Update.

Any ideas?

TIA,
Richard
 
P

Pegasus \(MVP\)

Try this:
- Click Start / Run / cmd {OK}
- Type these commands and report in each case what you see:
type c:\SayHello.bat{Enter}
assoc .bat{Enter}
 
R

Richard

Hello,

Download the Batch File Association Fix herehttp://www.dougknox.com/xp/file_assoc.htm

Thanks to both of you for your guidance.

I downloaded/extracted/ran .reg to repair the registration. It
reported success. However, double-clicking SayHello.bat in a new
Windows Explorer window failed. Also, the new window's File Types
displayed no BAT.

Maybe a reboot is necessary to 'clear XP's head". :)

But the good news is that running SayHello.bat in a Command window
worked now!! (It had not earlier today.)

Here's the results requested by Pegasus:

K:\_Projects\JavaScript\ScriptValidation>SayHello.bat
Hello
Press any key to continue . . .

K:\_Projects\JavaScript\ScriptValidation>assoc.bat
..bat=batfile

K:\_Projects\JavaScript\ScriptValidation>

I'll reboot just for kicks to see if that's relevant.

Best wishes,
Richard
 
P

Pegasus \(MVP\)

You don't appear to have a problem any more.


Richard said:
Thanks to both of you for your guidance.

I downloaded/extracted/ran .reg to repair the registration. It
reported success. However, double-clicking SayHello.bat in a new
Windows Explorer window failed. Also, the new window's File Types
displayed no BAT.

Maybe a reboot is necessary to 'clear XP's head". :)

But the good news is that running SayHello.bat in a Command window
worked now!! (It had not earlier today.)

Here's the results requested by Pegasus:

K:\_Projects\JavaScript\ScriptValidation>SayHello.bat
Hello
Press any key to continue . . .

K:\_Projects\JavaScript\ScriptValidation>assoc.bat
.bat=batfile

K:\_Projects\JavaScript\ScriptValidation>

I'll reboot just for kicks to see if that's relevant.

Best wishes,
Richard
 
R

Richard

You don't appear to have a problem any more.





Thanks to both of you for your guidance.

Hi Pegasus,

Perhaps my last post was unclear. I ran the .reg and got confirmation
that the Registry had been updated.

Apparently that led to a 50% improvement: my SayHello.bat executed
successfully when invoked in a Command window. Prior to the .reg
update, attempting to run the .bat file in a Command window was
rejected.

However, I still have 50% failure, even after re-booting: (1) Double-
clicking the .bat file's name in an Explorer window still fails; (2)
the File Types in the Explorer window still omits BAT; and (3) when I
add BAT and accept the "advanced" recommendation "MS-DOS Batch File"
by clicking OK, it get added at the top of the list but apparently
disappears after I close the Folder Options dialog.

Now I've gone a little further: After adding the BAT extension and
seeing it on the top of the Extensions list, I:
(1) clicked the Advance button
(2) noted that the edit action defaults to [[.....System32\Notepad.exe
%1]] use "Use DDE" checked
(3) noted that the open action defaults to [["%1" %*]]

I think the edit action is correct.

I think the open action is wrong, so before closing the Edit File Type
dialog, I changed the open action to
[[.....System32\cmd.exe /C "%1" %*]]

That seemed to come close to working: I double-clicked SayHello.bat
AND GOT A NOTEPAD WINDOW TO OPEN!
 
R

Richard

You don't appear to have a problem any more.

The problem is half solved: SayHello.bat now runs from within a
Command window. However, double-clicking SayHello.bat's name in an
Explorer window still produces the "not a Win32 program" complaint ...
despite the fact that I had rebooted :-(

I again looked at File Types and saw no BAT extension. I added it
again, and it appeared as the first item on the extensions list. This
time I clicked the Advanced button in File Types tab.

The action for "edit" invoked Notepad with a %1 argument ... looks
right to me.
The "open" action merely invoked %1 with some argument ... that looks
circular to me.

I modified the open action to "(fully qualified) cmd.exe /c
%1" (without the quotes). Now when I double-clicked SayHello.bat, I
didn't get the "Win32" complaint. Instead a got an empty Notepad
window. That's wrong, of course, but it's *progress* :)

I tried to go back and edit the .bat definition, but cannot find it
when I list the extensions alphabetically. When I try to re-enter BAT
as a new extension, I'm informed that "Extension bat is already
associated with File Type MS-DOS Batch File. I elected to un-
associate BAT, in which case it re-appeared at the top of the list.

This time, I clicked change but didn't get option to accept File Type
MS-DOS Batch File. I'm deleting the BAT extension and rerunning
the .reg file and see if things get any better.
 
R

Ramesh, MS-MVP

Richard,

In case that does not help, post the .BAT file association details here.

1. Download FileExtInfo.zip from here:
http://windowsxp.mvps.org/fileextinfo.htm

2. Unzip the utility and extract the files to Desktop.
3. Double-click "FileExtInfo.exe" to run it.
4. Select ".BAT" from the list
5. Click "View file association report"
6. Copy the contents of the report and include it in your reply.

--
Regards,

Ramesh Srinivasan, Microsoft MVP [Windows Shell/User]
Windows® Troubleshooting http://www.winhelponline.com


You don't appear to have a problem any more.

The problem is half solved: SayHello.bat now runs from within a
Command window. However, double-clicking SayHello.bat's name in an
Explorer window still produces the "not a Win32 program" complaint ...
despite the fact that I had rebooted :-(

I again looked at File Types and saw no BAT extension. I added it
again, and it appeared as the first item on the extensions list. This
time I clicked the Advanced button in File Types tab.

The action for "edit" invoked Notepad with a %1 argument ... looks
right to me.
The "open" action merely invoked %1 with some argument ... that looks
circular to me.

I modified the open action to "(fully qualified) cmd.exe /c
%1" (without the quotes). Now when I double-clicked SayHello.bat, I
didn't get the "Win32" complaint. Instead a got an empty Notepad
window. That's wrong, of course, but it's *progress* :)

I tried to go back and edit the .bat definition, but cannot find it
when I list the extensions alphabetically. When I try to re-enter BAT
as a new extension, I'm informed that "Extension bat is already
associated with File Type MS-DOS Batch File. I elected to un-
associate BAT, in which case it re-appeared at the top of the list.

This time, I clicked change but didn't get option to accept File Type
MS-DOS Batch File. I'm deleting the BAT extension and rerunning
the .reg file and see if things get any better.
 
R

Richard

You don't appear to have a problem any more.

Sorry for posting a half completed message.

Problem solved.

IMHO, the following lines in the .reg script are wrong:

[HKEY_CLASSES_ROOT\batfile\shell\open\command]
@="\"%1\" %*"

I used regedit to modify the default for that entry to:

%SystemRoot%\system32\Cmd.exe /C "%1" %*

(Actually, I had to substitute the value of %SystemRoot% on my system
because I couldn't figure out how to change the type from REG_SZ to
REG_EXPAND_SZ.).

Thanks for all your help.

Best wishes,
Richard
 
R

Richard

Richard,

In case that does not help, post the .BAT file association details here.

1. Download FileExtInfo.zip from here:
http://windowsxp.mvps.org/fileextinfo.htm

2. Unzip the utility and extract the files to Desktop.
3. Double-click "FileExtInfo.exe" to run it.
4. Select ".BAT" from the list
5. Click "View file association report"
6. Copy the contents of the report and include it in your reply.

--
Regards,

Ramesh Srinivasan, Microsoft MVP [Windows Shell/User]
Windows® Troubleshootinghttp://www.winhelponline.com


You don't appear to have a problem any more.

The problem is half solved: SayHello.bat now runs from within a
Command window. However, double-clicking SayHello.bat's name in an
Explorer window still produces the "not a Win32 program" complaint ...
despite the fact that I had rebooted :-(

I again looked at File Types and saw no BAT extension. I added it
again, and it appeared as the first item on the extensions list. This
time I clicked the Advanced button in File Types tab.

The action for "edit" invoked Notepad with a %1 argument ... looks
right to me.
The "open" action merely invoked %1 with some argument ... that looks
circular to me.

I modified the open action to "(fully qualified) cmd.exe /c
%1" (without the quotes). Now when I double-clicked SayHello.bat, I
didn't get the "Win32" complaint. Instead a got an empty Notepad
window. That's wrong, of course, but it's *progress* :)

I tried to go back and edit the .bat definition, but cannot find it
when I list the extensions alphabetically. When I try to re-enter BAT
as a new extension, I'm informed that "Extension bat is already
associated with File Type MS-DOS Batch File. I elected to un-
associate BAT, in which case it re-appeared at the top of the list.

This time, I clicked change but didn't get option to accept File Type
MS-DOS Batch File. I'm deleting the BAT extension and rerunning
the .reg file and see if things get any better.

Hi Ramesh,

Thanks for your offer of additional help. Please refer to my last
reply to Pegasus where I spell out my solution.

Best wishes,
Richard
 
R

Ramesh, MS-MVP

Hi Richard,

Thanks for the update! Glad you got this issue resolved.

--
Regards,

Ramesh Srinivasan, Microsoft MVP [Windows Shell/User]
Windows® Troubleshooting http://www.winhelponline.com


<snip>

Hi Ramesh,

Thanks for your offer of additional help. Please refer to my last
reply to Pegasus where I spell out my solution.

Best wishes,
Richard
 
P

Pegasus \(MVP\)

Richard said:
You don't appear to have a problem any more.

Sorry for posting a half completed message.

Problem solved.

IMHO, the following lines in the .reg script are wrong:

[HKEY_CLASSES_ROOT\batfile\shell\open\command]
@="\"%1\" %*"

I used regedit to modify the default for that entry to:

%SystemRoot%\system32\Cmd.exe /C "%1" %*

(Actually, I had to substitute the value of %SystemRoot% on my system
because I couldn't figure out how to change the type from REG_SZ to
REG_EXPAND_SZ.).

Thanks for all your help.

Best wishes,
Richard

Glad you got it resolved. However, there is a voice whispering
in the back of my mind that keeps asking: "How did all of this
happen in the first place?". Things don't usually go off the rails
by themselves . . .
 
R

Richard

Sorry for posting a half completed message.
Problem solved.
IMHO, the following lines in the .reg script are wrong:
[HKEY_CLASSES_ROOT\batfile\shell\open\command]
@="\"%1\" %*"
I used regedit to modify the default for that entry to:
%SystemRoot%\system32\Cmd.exe /C "%1" %*
(Actually, I had to substitute the value of %SystemRoot% on my system
because I couldn't figure out how to change the type from REG_SZ to
REG_EXPAND_SZ.).
Thanks for all your help.
Best wishes,
Richard

Glad you got it resolved. However, there is a voice whispering
in the back of my mind that keeps asking: "How did all of this
happen in the first place?". Things don't usually go off the rails
by themselves . . .
Sorry for posting a half completed message.
Problem solved.
IMHO, the following lines in the .reg script are wrong:
[HKEY_CLASSES_ROOT\batfile\shell\open\command]
@="\"%1\" %*"
I used regedit to modify the default for that entry to:
%SystemRoot%\system32\Cmd.exe /C "%1" %*
(Actually, I had to substitute the value of %SystemRoot% on my system
because I couldn't figure out how to change the type from REG_SZ to
REG_EXPAND_SZ.).
Thanks for all your help.
Best wishes,
Richard

Glad you got it resolved. However, there is a voice whispering
in the back of my mind that keeps asking: "How did all of this
happen in the first place?". Things don't usually go off the rails
by themselves . . .

Hi Pegasus,
How did all of this happen in the first place?

Good question. I'm a retired software developer, a majority of the
time on Windows platforms. So I run pretty good security (haven't had
a virus in years, since I installed Win2K, I think) and don't open
strange links or download from strange sites. So I don't have a
clue. I chalk it up to "S*** happens!"

The upside to this, aside from the wonderful advice from three of
you, is that I learned about Windows® XP File Association Fixes. I'm
disappointed that RegEdit doesn't allow one to change the type of an
existing entry, or perhaps even set the REG_EXPAND_SZ type for a new
entry, AFAIK.

I think that's why the batch_file_assoc.reg script resorts to hex for
defining [HKEY_CLASSES_ROOT\batfile\shell\edit\command]
while using a simple string for defining [HKEY_CLASSES_ROOT\batfile
\shell\open].

Of course, a simple string was adequate in the latter case because the
author omitted %SystemRoot%, etc. in the definition. Had he done so,
it seems to me he would have had to resort to hex.

I'm going to try to email the site's maintainer to relate my belief
that shell\open needs to corrected.

The bottom line for me is that using computers now-a-days would be
intolerable, were it not for folks like you all who contribute the
hard-earned knowledge to the rest of us.

Best wishes,
Richard
 

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