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.
Answer
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!
)
No comments:
Post a Comment