Paths and Path Extensions

C

Confused

Something I've been wondering about but never remember to ask ...

1. In My Computer > Properties > Advanced > Environmental Variables
there is a section named System Variables in which PATHEXT is defined.
On my own system this consists of the following:

".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH"

My assumption was that the .EXE extension was there to allow one to
execute programs at the command-line without having to type the trailing
..EXE extension. If that's correct, why then can one not execute files
having any of the extensions listed?

2. My second question concerns "User Variables" and System Variables.
The difference seems obvious, but I remember having path-related
problems by adding a new path to User Variables. Adding a path to
System Variables always corrected the problem. Could someone explain
whether:

a) My memory sucks; or
b) The correct usage for these two.

Thanks.
 
P

Pegasus \(MVP\)

See below.


Confused said:
Something I've been wondering about but never remember to ask ...

1. In My Computer > Properties > Advanced > Environmental Variables
there is a section named System Variables in which PATHEXT is defined.
On my own system this consists of the following:

".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH"

My assumption was that the .EXE extension was there to allow one to
execute programs at the command-line without having to type the trailing
.EXE extension.
Correct.

If that's correct, why then can one not execute files
having any of the extensions listed?

"One" in this context means "you", not other people. There is
something wrong with your settings. If you want to execute
abc.exe, then one of the following three conditions must be met:
- abc.exe must reside in the current folder, or
- abc.exe must reside in one of the folders listed in %path%, or
- you must supply a full address, e.g. "c:\program files\abc.exe".

2. My second question concerns "User Variables" and System Variables.
The difference seems obvious, but I remember having path-related
problems by adding a new path to User Variables. Adding a path to
System Variables always corrected the problem. Could someone explain
whether:

a) My memory sucks; or
b) The correct usage for these two.

Thanks.

User variables, as the heading in the Control Panel says, are valid
for the current user. System variables apply to all users. Things like
%path% are always defined as system variables. Temporary directories
are defined as user variables. If you wish to define the %path% in the
user panel then you need to determine how it is married with the
system %path% variable. Set it, log off & on again, start a Command
Prompt and type path .
 
E

End User

"Pegasus \(MVP\)" said:
See below.




Correct.

So far so good said:
"One" in this context means "you", not other people. There is
something wrong with your settings. If you want to execute
abc.exe, then one of the following three conditions must be met:
- abc.exe must reside in the current folder, or
- abc.exe must reside in one of the folders listed in %path%, or
- you must supply a full address, e.g. "c:\program files\abc.exe".

Oops. Maybe I wasn't clear. What I don't understand is why the EXE
extension is unique when that extension is defined along with a host of
others as "path extensions."

For example, typing "abc" at the command prompt will start "abc.exe" if
there is an executable with that name located somewhere in the path.
That part I've never had a problem with.

However, typing "xyz" (to execute a script named "xyz.bat" located
somewhere in the path) will NOT execute that script, nor will it execute
"xyz.cmd", "xyz.vbs", "xyz.vbe" or any file which has an extension
that's defined (along with the EXE) in the path extensions dialog box.
The full name of the script including the extension must be typed in
each case.

So, am I not understanding what "path extensions" really are, or do they
have some usage unrelated to the command prompt?
User variables, as the heading in the Control Panel says, are valid
for the current user. System variables apply to all users. Things like
%path% are always defined as system variables. Temporary directories
are defined as user variables. If you wish to define the %path% in the
user panel then you need to determine how it is married with the
system %path% variable. Set it, log off & on again, start a Command
Prompt and type path .

Gotcha. Must be that I've been forgetting (or ignoring) the logoff part.

Thanks again!
 
P

Pegasus \(MVP\)

See below.


End User said:
Oops. Maybe I wasn't clear. What I don't understand is why the EXE
extension is unique when that extension is defined along with a host of
others as "path extensions."

For example, typing "abc" at the command prompt will start "abc.exe" if
there is an executable with that name located somewhere in the path.
That part I've never had a problem with.

I strongly disagree. I have a folder c:\tools. In this folder I have several
batch files, e.g. int.bat. I can now type "int", or "int.bat" from anywhere
in a Command Prompt, and the batch file will execute. What exactly
happens when you do this?

As I said before: There appears to be something strange with your
system. Maybe a scan with an external virus scanner, e.g. on
www.antivirus.com ("free online scan") might be in order.
 
T

Torgeir Bakken (MVP)

Pegasus (MVP) said:
"One" in this context means "you", not other people. There is
something wrong with your settings. If you want to execute
abc.exe, then one of the following three conditions must be met:
- abc.exe must reside in the current folder, or
- abc.exe must reside in one of the folders listed in %path%, or
- you must supply a full address, e.g. "c:\program files\abc.exe".

Hi

Yo can add a forth:

- abc.exe must be defined under the registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\

(note that to get this to work from a command prompt you will need to use
"start" to launch the file)
 
C

Charlie Li

Hi,

Thank you for your post.

To clarify the issue, I suggest you do the following:

1. Create a new folder in C: such as C:\Test.
2. Create a new bat file such as 123.bat and type some simple commands such
as dir or ping 127.0.0.1.
3. Go to command prompt, switch to C:\test, type 123 to see if it works.

If the bat file cannot execute, please let me know the detailed error
message it returns.

Then please go to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment to see if the Pathext value has the correct data.

In Addition, Torgeir's suggestion on modifing
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\ may
be helpful, please try it at the same time.

If you have any concerns, please feel free to let me know.

Have a nice day.

Sincerely,

Charlie Li
MCSE/MCDBA/MCSA
Microsoft Partner Online Support


Get Secure! - www.microsoft.com/security

====================================================
When responding to posts, please "Reply to Group" via
your newsreader so
that others may learn and benefit from your issue.
====================================================
This posting is provided "AS IS" with no warranties, and
confers no rights.
 
C

Charlie Li

Hi Pegasus and Torgeir,

Thank you for sharing your experience in newsgroup.

Have a nice day.

Sincerely,

Charlie Li
MCSE/MCDBA/MCSA
Microsoft Partner Online Support


Get Secure! - www.microsoft.com/security

====================================================
When responding to posts, please "Reply to Group" via
your newsreader so
that others may learn and benefit from your issue.
====================================================
This posting is provided "AS IS" with no warranties, and
confers no rights.
 

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