Failed running .bat file from WinXP Explorer

R

Richard

Hi,

I'm having brain cramps: I double-clicked a filename "Test.bat"
displayed in Windows Explorer under WinXP/SP2, which up-to-date with
Windows Update.

I got a message box claiming "K:\_Utilities\FreeRIDE\Test.bat is not a
valid Win32 application." If I open a command window to invoke
the .bat file, it works fine.

The file and its execution follows. Any ideas?

Thanks in advance,
Richard

====== Test.bat =====
echo Hello, World
== === end ====


====== Command Prompt window ===
K:\_Utilities\FreeRIDE>Test

K:\_Utilities\FreeRIDE>echo Hello, World
Hello, World

K:\_Utilities\FreeRIDE>
========= end ==========
 
A

Ayush

Replied to [Richard]s message :
Hi,

I'm having brain cramps: I double-clicked a filename "Test.bat"
displayed in Windows Explorer under WinXP/SP2, which up-to-date with
Windows Update.

I got a message box claiming "K:\_Utilities\FreeRIDE\Test.bat is not a
valid Win32 application." If I open a command window to invoke
the .bat file, it works fine.

Run the BAT File Fix :
http://www.dougknox.com/xp/file_assoc.htm
 
R

Richard

Hi Ayush,

Thanks for responding. I checkout the entry you recommended and
applied it, to no avail. Weird, eh?

I might just add that until about a week ago, my WinXP/SP2 has been
very stable and virus free. I use AVG Free Edition, PC Mag's Startup
Cop and PrevX. However, I updated to IE7 last week and the browser is
broken in one respect: it won't open my ISP's home page (it goes into
an infinite loop.) Other sites seem to be OK.

I provide all the gory details below. These details are very readable
in my Log written with the formatting provided by MS Word. With less
formatting control in the newsgroup, I hope it's not inscrutable.

Best wishes,
Richard

• http://www.computerhope.com/issues/ch000726.htm
o REFERENCE NUMBER: CH000726
o Not a valid Win32 application
o Created FixAutoConfig.bat
:: Open a Command Window:
:: Click Start | Run
:: Enter the command cmd.exe
:: Run this file (or copy/paste the follow commands
into the Command Window)
::
:: Switch to the drive housing Windows
%homedrive%
:: Change Directory to the Repair Directory
cd %windir%\Repair
:: Copy startup files for WinXP DOS subsystem
copy autoexec.nt %windir%\system32
copy config.nt %windir%\system32
::
@echo Reboot your system
@pause

:: Values 2/4/2007 of %homedrive%\autoexec.bat
:: PATH=%PATH%;F:\PROGRA~1\MICROS~1.NET
\Common7\Tools
:: vsvars32.exe
o Ran FixAutoConfig.bat in a Command Window:
Copied Autoexec.NT/Config.NT from Repair to System32
C:\>K:\_Utilities\RepairToolsForWindows
\RepairAutoexecConfig\FixAutoConfig.bat

C:\>F:

F:\>cd F:\WINXPPRO\Repair

F:\WINXPPRO\repair>copy autoexec.nt F:\WINXPPRO
\system32
1 file(s) copied.

F:\WINXPPRO\repair>copy config.nt F:\WINXPPRO
\system32
1 file(s) copied.
Reboot your system
Press any key to continue . . .
o Rebooted
o Tested in a Command Window with K:\_Utilities\FreeRIDE> run.bat
FreeRIDE window opened
o Double-clicked run.bat
Got K:\_Utilities\FreeRIDE\run.bat is not a valid Win32
application.



Replied to [Richard]s message :
I'm having brain cramps: I double-clicked a filename "Test.bat"
displayed in Windows Explorer under WinXP/SP2, which up-to-date with
Windows Update.
I got a message box claiming "K:\_Utilities\FreeRIDE\Test.bat is not a
valid Win32 application." If I open a command window to invoke
the .bat file, it works fine.

Run the BAT File Fix :http://www.dougknox.com/xp/file_assoc.htm
 
R

Richard

Hi Ayush,

Thanks for responding. I followed your suggestion, as the details
below will show, but updating the Registry using the recommended site
did not improve my system's performance.

Below are notes from my log outlining what I did and the results I
got.

Again, I appreciate your taking the time to help. If you have any
further ideas, I'd be pleased to receive them.

Best wishes,
Richard

• http://www.computerhope.com/issues/ch000726.htm
o Downloaded/opened .zip file
o Extracted batch_file_assoc.reg to folder
o Ran it in a Command Window
Got a “Are you sure†dialog ... clicked OK
Got a confirmation msg the Registry was updated
o Tested in a Command Window with K:\_Utilities\FreeRIDE>
run.bat
FreeRIDE window opened
o Double-clicked run.bat
Got K:\_Utilities\FreeRIDE\run.bat is not a valid
Win32 application.



Replied to [Richard]s message :
I'm having brain cramps: I double-clicked a filename "Test.bat"
displayed in Windows Explorer under WinXP/SP2, which up-to-date with
Windows Update.
I got a message box claiming "K:\_Utilities\FreeRIDE\Test.bat is not a
valid Win32 application." If I open a command window to invoke
the .bat file, it works fine.

Run the BAT File Fix :http://www.dougknox.com/xp/file_assoc.htm
 
R

Richard

Hi Ayush,

Thanks for responding. I followed your suggestion, as the details
below will show, but updating the Registry using the recommended site
did not improve my system's performance.

Below are notes from my log outlining what I did and the results I
got.

Again, I appreciate your taking the time to help. If you have any
further ideas, I'd be pleased to receive them.

Best wishes,
Richard


• http://www.dougknox.com/xp/file_assoc.htm
o Downloaded/opened .zip file
o Extracted batch_file_assoc.reg to folder
o Ran it in a Command Window
Got a “Are you sure†dialog ... clicked OK
Got a confirmation msg the Registry was
updated
o Tested in a Command Window with K:\_Utilities
\FreeRIDE> run.bat
FreeRIDE window opened
o Double-clicked run.bat
Got K:\_Utilities\FreeRIDE\run.bat is not a
valid Win32 application.


Replied to [Richard]s message :
I'm having brain cramps: I double-clicked a filename "Test.bat"
displayed in Windows Explorer under WinXP/SP2, which up-to-date with
Windows Update.
I got a message box claiming "K:\_Utilities\FreeRIDE\Test.bat is not a
valid Win32 application." If I open a command window to invoke
the .bat file, it works fine.

Run the BAT File Fix :http://www.dougknox.com/xp/file_assoc.htm
 
R

Richard

Hi Wes,

Thanks for responding and inviting me to report back. I checked out
the entry you recommended and applied it, to no avail. Weird, eh?

As I told Ayush in an earlier post, I might just add that until about
a week ago, my WinXP/SP2 has been very stable and virus free. I use
AVG Free Edition, PC Mag's Startup Cop and PrevX. However, I updated
to IE7 last week and the browser is broken in one respect: it won't
open my ISP's home page (it goes into an infinite loop.) Other sites
seem to be OK.

I provide all the gory details of my failure below. These details are
very readable in my Log, as they were written with the formatting
power provided by MS Word. With less formatting control in the
newsgroup, I hope it's not inscrutable.

If you have any other idea about this crazy symptom, I'd be glad to
hear about it. Incidentally, I put together a WSH script workaround
which I'll offer to the FreeRIDE group and use myself. It works well
except it generates a spurious MessageBox when FreeTRIDE is
terminated. In case you're interested, I've included the script at
the very end of this post.

Best wishes,
Richard

· http://www.computerhope.com/issues/ch000726.htm
o REFERENCE NUMBER: CH000726
o Not a valid Win32 application
o Created FixAutoConfig.bat
:: Open a Command Window:
:: Click Start | Run
:: Enter the command cmd.exe
:: Run this file (or copy/paste the follow commands
into the Command Window)
::
:: Switch to the drive housing Windows
%homedrive%
:: Change Directory to the Repair Directory
cd %windir%\Repair
:: Copy startup files for WinXP DOS subsystem
copy autoexec.nt %windir%\system32
copy config.nt %windir%\system32
::
@echo Reboot your system
@pause
:: Values 2/4/2007 of %homedrive%\autoexec.bat
:: PATH=%PATH%;F:\PROGRA~1\MICROS~1.NET
\Common7\Tools
:: vsvars32.exe
o Ran FixAutoConfig.bat in a Command Window:
Copied Autoexec.NT/Config.NT from Repair to System32
C:\>K:\_Utilities\RepairToolsForWindows
\RepairAutoexecConfig\FixAutoConfig.bat
C:\>F:
F:\>cd F:\WINXPPRO\Repair
F:\WINXPPRO\repair>copy autoexec.nt F:\WINXPPRO
\system32
1 file(s) copied.
F:\WINXPPRO\repair>copy config.nt F:\WINXPPRO
\system32
1 file(s) copied.
Reboot your system
Press any key to continue . . .
o Rebooted
o Tested in a Command Window with K:\_Utilities\FreeRIDE>
run.bat
FreeRIDE window opened
o Double-clicked run.bat
Got K:\_Utilities\FreeRIDE\run.bat is not a valid
Win32 application.


=========== RunFreeRIDE.js ===========
// Requires Windows Script Host ... free from Microsoft at:
// http://www.microsoft.com/downloads/details.aspx?
displaylang=en&FamilyID=C717D943-7E4B-4622-86EB-95A22B832CAA

var pgm = "rubyw.exe -rubygems freeride.rb";

var WshShell = new ActiveXObject("WScript.Shell");
var oExec = WshShell.Exec(pgm);
while (oExec.Status == 0)
{
WScript.Sleep(100);
}
WScript.Echo("freeRIDE Exit Status = " + oExec.Status);
 
R

Richard

Wes,

You probably don't want to be bothered with all the details of my
FixAutoConfig.bat script, but for the record I should mention that a
comment in that script is incorrect.

I reported at the end of it that:
:: Values 2/4/2007 of %homedrive%\autoexec.bat
:: PATH=%PATH%;F:\PROGRA~1\MICROS~1.NET
\Common7\Tools
:: vsvars32.exe

The first line should say:
:: Values 2/4/2007 of C:\autoexec.bat

I know the C:\autoexec.nt file is processed because I can run Visual
Studio by virtue of the PATH statement and I can you symbols in C++
without #include statements. The fact that a C:\autoexec.nt is used
by Windows, I suspicious about whether another autoexec.nt in %windir%
\system32 will really have an effect. Just a thought ...

Best wishes,
Richard
 
R

Richard

Wes,

You probably don't want to be bothered with all the details of my
FixAutoConfig.bat script, but for the record I should mention that a
comment in that script is incorrect.

I reported at the end of it that:
:: Values 2/4/2007 of %homedrive%\autoexec.bat
:: PATH=%PATH%;F:\PROGRA~1\MICROS~1.NET
\Common7\Tools
:: vsvars32.exe

The first line should say:
:: Values 2/4/2007 of C:\autoexec.nt

I know the C:\autoexec.nt file is processed because I can run Visual
Studio by virtue of the PATH statement and I can use Windows symbols
in C++ without #include statements. The fact that a C:\autoexec.nt is
actually used by Windows, I'm suspicious about whether another
autoexec.nt in %windir%\system32 will really have an effect. Just a
thought ...

Best wishes,
Richard
 
W

Wesley Vogel

Hi Richard,
but for the record I should mention that a
comment in that script is incorrect.

:)

Any comments to the right of rem or :: should be ignored.

If you use >> anything to the right will be echoed in the command prompt.

I.e. >> Values 2/4/2007 of C:\autoexec.bat

If you use :: Values 2/4/2007 of C:\autoexec.bat
or rem Values 2/4/2007 of C:\autoexec.bat
it will be ignored as a comment.

The environmental variable Pathext shows a list of file extensions that are
considered to be executable and regulates which extensions do not need to be
typed in a Command or Run window.

What does PATHEXT show?

Open a command prompt, type: set hit Enter and scroll to PATHEXT.

At a minimum, PATHEXT should look something like this...
PATHEXT=.COM;.EXE;.BAT;.CMD

Mine has...
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH

See My Pathext Experiment below. Way below. ;-)

You can add F:\PROGRA~1\MICROS~1.NET\Common7\Tools to your Environment
Variables.

System environment variables are in the following Registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\
Control\Session Manager\Environment
Fro Example... Value Name: Path & Value Name: PATHEXT

If you add to the PATH variable, by doing the following...

To view or change environment variables:
1. Right-click My Computer, and then click Properties.
2. Click the Advanced tab.
3. Click Environment variables.
4. Click one the following options, for either a user or a system variable:
* Click New to add a new variable name and value.
* Click an existing variable, and then click Edit to change its name or
value.
* Click an existing variable, and then click Delete to remove it.
from...
HOW TO Manage Environment Variables in Windows XP
http://support.microsoft.com/kb/310519

You can have F:\PROGRA~1\MICROS~1.NET\Common7\Tools show up any time when
you type path or set in a command prompt without having to set the path in
autoexec.bat. It will always be in the PATH.

If you set the path in the autoexec.bat, path probably gets added in this
registry key.
HKEY_CURRENT_USER\Volatile Environment
This registry key applies to current logon session and is not saved between
logoffs and
restarts.
---------------

My Pathext Experiment 27 August, 2006.

I just created a tracert.com in my System32 folder.

I opened a command prompt, typed: tracert /? and hit Enter.

This error message popped up...

---------------------------
C:\WINDOWS\system32\tracert.com
---------------------------
C:\WINDOWS\system32\tracert.com is not a valid Win32 application.

---------------------------
OK
---------------------------

I clicked OK and
Access is denied.
appeared in the command prompt.
-----

I still have the tracert.com that I created.

I removed everything from, my PATHEXT environment variable.

Opened a command prompt, typed: tracert and hit Enter.

I got the C:\WINDOWS\system32\tracert.com is not a valid Win32 application
error.

I clicked OK.

I got the Access is denied.

I typed: tracert.com and hit Enter.

I got the C:\WINDOWS\system32\tracert.com is not a valid Win32 application
error.

I clicked OK.

I got the Access is denied.

I typed: tracert.exe and hit Enter.

That command worked.

I deleted tracert.com.

I typed: tracert and hit Enter.

And it worked.

That confused me, so I typed: set and hit Enter.

PATHEXT still showed
=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH

So I opened the Registry Editor and navigated to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\
Session Manager\Environment

PATHEXT was empty.

I restored tracert.com to System32.

I rebooted.

I opened a command prompt, typed set and hit Enter.

PATHEXT showed
=.COM;.EXE;.BAT;.CMD;.VBS;.JS;.WS

I did a search for .COM;.EXE;.BAT;.CMD;.VBS;.JS;.WS in the registry.

Found nothing.

I did a search for .COM;.EXE;.BAT in the registry.

Found nothing.

Hmmm.

I put
..COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
back into PATHEXT environment variable.

PATHEXT is now OK in both
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment
and
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment

I deleted tracert.com from System32.

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In
 
R

Richard

Hi Wes,

Thanks for the additional feedback.
Any comments to the right of rem or :: should be ignored.

I know. Those comments were intended to inform you that:
1. The root of my startup partition, designated as C:\, contained an
autoexec.nt file
2. That .NT file is used by WinXP on boot-up, which I'm quite sure
about because I needed (for Visual C++ programming):
2a. "vsvars32.exe" run on startup to define symbols
2b. "F:\PROGRA~1\MICROS~1.NET\Common7\Tools" appended to the path
2c. and those needs were met when I modified that .NT file.

The main point I wanted to make was that there's a working autoexec.nt
in C:\, while the http://www.computerhope.com/issues/ch000726.htm
thing targeted %HOMEDIR%\system32\autoexec.nt. That seemed strange to
me.

I checked PATHEXT, both in a command window:
K:\>echo %pathext%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.RB;.RBW
and HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
yielded the same result.
You can add F:\PROGRA~1\MICROS~1.NET\Common7\Tools to your Environment
Variables.
Agreed. I like keeping with the path addition with "vsvars32.exe",
which of course I can't put in an environment variable, and its not
worth the trouble to add it to a startup entry in the Registry.
"My Computer/Properties" is a nice way to get to the env. variables.
I keep desktop icons for Display, System, Services, Admin. Tools that
I find handy for system management.
My Pathext Experiment 27 August, 2006.
I followed your investigation for a while. Then a Eureka moment
occurred to me. Let me know what you think about it:

I surmised that the purpose of the PATHEXT variable is:
1. Microsoft designed the shell to treat anything without an extension
in a Command Window as a command.
2. But commands really need an extension so that the association with
an executable file can be honored
3. PATHEXT exists to define what possible extensions should be tried
with the putative, given "no-extension command"

That hypothesis led me to think that the run.bat command for
FreeRIDE:
: Original command commented out by me (RLM)
: freeruby-win\bin\ruby.exe -rubygems freeride.rb
: Revised command that I couldn't get working:
ruby -rubygems freeride.rb
is unnecessary.

We can simply type "FreeRIDE" in a Command Window (whose current
working directory is the FreeRide folder) and, voila, the FreeRIDE API
for Ruby programming appears. How does this magic occur? I think the
Windows command.com processor:
1. searches the current directory for a file name freeride.xxx, where
xxx is any of the extensions listed in PATHTXT
2. finds freeride.rb
3. looks up the association with that extension, which is Ruby.exe
(and its folder is on the PATH)
4, invokes Ruby.exe passing along the fully qualified name K:
\_Utilities\FreeRIDE\freeride.rb

"K:\_Utilities\FreeRIDE\freeride.rb" also works in Start | Run,
though it finds it necessary to open a Command window first.

I got the FreeRIDE to come up from Start | Run | FreeRIDE | FreeRIDE.

Unfortunately, FreeRIDE (with no extension) in Start/Run opens the
FreeRIDE Explorer window rather than the API.
And FreeRIDE.rb (with no path) in Start/Run fails, because the shell
only searches a few places for a program.

One last detail: the -rubygems in the original run.bat command is
unnecessary IMHO when FreeRIDE is already installed on the system in
question. "rubygems" is an installation system for Ruby programs and
plugins.

Bottom line: I got around the initial problem I had initially. The
FreeRIDE IDE needs some work.

Again, thank you for sharing your thinking about this problem.

Best wishes,
Richard
 
W

Wesley Vogel

Hi Richard,
The main point I wanted to make was that there's a working autoexec.nt
in C:\, while the http://www.computerhope.com/issues/ch000726.htm
thing targeted %HOMEDIR%\system32\autoexec.nt. That seemed strange to
me.

%SystemRoot%\System32 or C:\WINDOWS\System32 is where Autoexec.nt and
Config.nt belong.

I have two copies of Autoexec.nt, one each in...
C:\WINDOWS\system32
and
C:\WINDOWS\repair

I have two copies of Config.nt, one each in...
C:\WINDOWS\system32
and
C:\WINDOWS\repair

The copies in C:\WINDOWS\repair are backup copies created when XP was
installed.

And I have one AUTOEXEC.BAT and one CONFIG.SYS in C:\ and they are both
*totally* empty.

Some evidence on where Config.nt and Autoexec.nt belong.

<quote>
1. Using a text editor, such as Notepad, edit the Config.nt and Autoexec.nt
files (located in systemroot\System32).
<quote>
Microsoft Windows XP - Create custom startup files for an MS-DOS-based
program
http://www.microsoft.com/resources/...n-us/windows_dos_custom_startup.mspx?mfr=true

<quote>
4. At the command prompt, type the following commands, pressing ENTER after
each command:
expand CD-ROM Drive Letter:\i386\config.nt_ c:\windows\system32\config.nt
expand CD-ROM Drive Letter:\i386\autoexec.nt_
c:\windows\system32\autoexec.nt
APPLIES TO
Microsoft Windows XP Professional
Microsoft Windows XP Home Edition
<quote>
http://support.microsoft.com/kb/324767

<quote>
Check the Config.nt and Autoexec.nt files in the %SystemRoot%\System32
folder

Enter these lines in the Config.nt and Autoexec.nt files in the
%SystemRoot%\System32 folder.
APPLIES TO
Microsoft Windows XP Home Edition
Microsoft Windows XP Professional
I surmised that the purpose of the PATHEXT variable is:

The environmental variable Pathext shows a list of file extensions that are
considered to be executable and regulates which extensions do not need to be
typed in a Command Prompt or the Run command.

The Path environmental variable and a registry entry, App Paths,
control what paths do not have to be typed.

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\
CurrentVersion\App Paths\somefile.exe
Value Name: Path
Data Type: REG_EXPAND_SZ
Value Data: Path to executable

If a path is in App Paths, that path does not need to be in the PATH
environment variable. Take msconfig.exe, for example.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\
CurrentVersion\App Paths\MSCONFIG.EXE
Value Name: (Default)
Data Type: REG_SZ
Value Data: C:\WINDOWS\PCHealth\HelpCtr\Binaries\MSConfig.exe

You can type: msconfig in the Run command or use start msconfig in
a command prompt. You do not need the path or the extension.

Extensions to look for and in what order.

When you run a command that does not contain an extension, Cmd.exe uses the
value of the PATHEXT environment variable to determine which extensions to
look for and in what order. The default value for the PATHEXT variable is:

..COM;.EXE;.BAT;.CMD

(that is, the syntax is the same as the PATH variable, with semicolons
separating the different elements).

When searching for an executable, if there is no match on any extension,
then looks to see if the name matches a directory name. If it does, the
START command launches the Explorer on that path. If done from the command
line, it is the equivalent to doing a CD /D to that path.

When you search for an executable and there is no match on any extension,
start searches directory name. If it does, start opens Explorer.exe on that
path.
from...
Start
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/start.mspx
and start /? in a command prompt.

If you have files named My_Whatever.COM, My_Whatever.EXE My_Whatever.BAT and
My_Whatever.CMD, if you type My_Whatever with no extension My_Whatever.COM
will be found FIRST, then My_Whatever.EXE, then My_Whatever.BAT and then
My_Whatever.CMD.

That's why malware screws people up. Malware will create a file called
cmd.com and place it in the system32 folder. A poor guy types cmd in
the Run command and the command prompt doesn't open for him and he gets a 16
bit MS-DOS Subsystem error instead. If they type cmd.exe in the Run
command the command prompt might open.

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In
 

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