1

What is the default value for the PATHEXT environment variable for different versions of Windows? Or even better: How can you reliably determine the original default system value for PATHEXT on a system when it may have been modified by installed software, group policy, etc?

I'm interested in Windows 7, 8, and 10 at a minimum. Unfortunately I don't have any fresh systems to check this on.

For general pedagogy: the environment variable PATHEXT defines what file extensions Windows considers as executable commands. For example, my system has:

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

When you type a command into cmd.exe such as explorer Windows will search for files with these extensions (in this order) to determine whether to execute the application/file. explorer will typically resolve to explorer.exe which is found in the PATH at c:\windows\explorer.exe.

  • 1
    Working on a Corporate Windows 7 system, it is the same as the list you have above. – Leptonator Jan 16 '16 at 5:38
2

The default value in Windows XP: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH

The default value in Windows Vista, 7, 8 and 10 - have also confirmed in Server 2008 R2: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

If your value isn't the same as this, it's been modified, these are the default out-of-the-box values. .MSC is the only addition since Windows XP, a Microsoft Management Console Snap-in Control File, used for things such as Group Policy Editor gpedit.msc.

Further reading: Wikipedia

You could run the following batch, or a variation of it, to quickly see if they'd been changed.

@echo off
setlocal
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j

IF "%version%" == "5.1" GOTO windowsxp
IF "%version%" == "5.2" GOTO windowsxp

:windowsabovexp

set "PATHEXTORIGINAL=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"

GOTO compare

:windowsxp

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

:compare

if not "%PATHEXT%" == "%PATHEXTORIGINAL%" (
   echo PATHEXT has been modified!
) else (
   echo PATHEXT is expected!
)
  • Do you know how someone could verify the value for a particular version of Windows? – ebpa Jan 16 '16 at 6:12
  • @ebpa Do you mean other than just looking at the value in %PATHEXT%? – Jonno Jan 16 '16 at 6:14
  • Yes. Presumably the historical authoritative (original default) value remains intact on the system and can be examined. The registry value can't necessarily be trusted. I don't doubt your answer; this is just intellectual curiosity. Perhaps I should spawn off a separate question since this applies to environment variables in general... – ebpa Jan 16 '16 at 6:25
  • @ebpa I don't believe the defaults are stored anywhere, they would be likely just be put in place during installation as there is no 'reset to default setting' anywhere for environmental variables. I've added to my answer a batch you could use to quickly verify if a modification has been made, but otherwise I highly doubt there being an 'in-built' verification. – Jonno Jan 16 '16 at 6:31
0

With a little bit of work, you could do some validation using a batch script:

FOR /F "tokens=* delims=;" %%A IN (".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC") DO @echo %%A

NOTE: The above example is for use in a batch file. If you want to run directly on a CMD prompt, change %%A to just %A to see the results.

Then, you could compare or count the results. If it does not match, send an alert, for example.

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.