What is the default value of the PATHEXT environment variable for Windows?

6,923

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!
)
Share:
6,923

Related videos on Youtube

ebpa
Author by

ebpa

Updated on September 18, 2022

Comments

  • ebpa
    ebpa over 1 year

    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.

    • Leptonator
      Leptonator over 8 years
      Working on a Corporate Windows 7 system, it is the same as the list you have above.
  • ebpa
    ebpa over 8 years
    Do you know how someone could verify the value for a particular version of Windows?
  • Jonno
    Jonno over 8 years
    @ebpa Do you mean other than just looking at the value in %PATHEXT%?
  • ebpa
    ebpa over 8 years
    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...
  • Jonno
    Jonno over 8 years
    @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.