When you open a CMD prompt and type PATH, the PATH variable that is displayed is a compound construct, composed of:

1. The System PATH - Control Panel / System / Advanced / Environment variables.

2. The User PATH - Control Panel / System / Advanced / Environment variables.

3. The PATH from C:\AUTOEXEC.BAT, unless Parseautoexec is set to 0.

I have created a logon script extension to check for and post duplicate path entries.

To use it:

1. Create a folder on each LOGONSERVER and share it as NetShare.

2. Share permissions should be the default Full Control for Everyone.

3. Set the NTFS permissions as follows:

        Uncheck Allow inheritable permissions from parent to propagate to this object.

        Grant SYSTEM and Administrators Full Control.

        Grant Everyone and Authenticated Users Read & Execute, List Folder Contents, Read and Write permissions.

        Grant CREATOR OWNER Modify permissions.

4. Copy PathCheck.bat (below) to the NetShare shared folder.

5. Copy Reg.exe from the Windows 2000 Support Tools, or from %WinDir%\System32 of a Windows XP Professional installation, or from Supplement 4 of the Windows NT 4.0 Resource Kit, to the NetShare shared folder.

5. Add the following line to your logon script:

call %logonserver%\Netshare\pathcheck.bat

PathCheck.bat will write the results of its' checking to the NetShare folder on the %logonserver% as %computername%_%username%.<extension>, where <extension> is log if there are no duplicates, and err if duplicates exist.

At subsequent a logon, the presence of a %computername%_%username%.log file will immediately exit the routine.

The %computername%_%username%.log file will contains 3 lines, similar to:

syspath=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\system32\WBEM;C:\WIN_ONE;C:\Perl\bin;C:\Program Files\Resource Kit\;                                      C:\UTIL;C:\Program Files\Executive Software\Undelete\;                                      C:\Program Files\Microsoft Office\Office;F-PROT;c:\Program Files\Support Toolsusrpath=C:\ZIPNEW;c:\util                              autpath=C:\util;C:\ZIPNEW
The %computername%_%username%.err file will contain the same 3 lines, preceded by n lines in the form of Dup=<Duplicate Path Entry>.

Pathcheck.bat contains:

@echo on                              if /i not "%OS%" EQU "Windows_NT" goto :EOF                              if exist %logonserver%\NetShare\%computername%_%username%.log goto :EOF                              setlocal                              pushd %logonserver%\NetShare                              set totpath=%path%;                              set totpath=%totpath:;;=;%                              for /f "Skip=2 Tokens=1,2*" %%i in ('REG QUERY "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" /v PATH') do set syspath=%%k                              for /f "skip=2 Tokens=*" %%i in ('REG QUERY "HKCU\Environment"') do set line=%%i&call :usr                              for /f "skip=2 Tokens=*" %%i in ('REG QUERY "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon"') do set line=%%i&call :auto                              if not "%autoexec%"

"" goto ok set autoexec=1 call :auto1 :ok set totpath=%totPATH:;=#% :loop if "%totpath%" EQU "ECHO is on." goto :finish for /f "Tokens=1* Delims=#" %%i in ('@echo %totpath%') do set folder=%%i# set folder=%folder: #=% set work=*%folder% set totpath=*%totpath% for /f "Tokens=*" %%k in ('@echo %%totpath:%work%^=%%') do set totpath=%%k for /f "Tokens=*" %%k in ('@echo %%totpath:%folder%^=%%') do set work=%%k if "%totpath%" EQU "%work%" goto :loop set folder=%folder:#=% set totpath=%work% if not "%ext%"

"" goto err set ext=err @echo Dup=%folder%>%computername%_%username%.err goto :loop :err @echo Dup=%folder%>>%computername%_%username%.err goto :loop :finish if not "%ext%"

"" goto finish1 set ext=log @echo syspath=%syspath%>%computername%_%username%.log goto finish2 :finish1 @echo syspath=%syspath%>>%computername%_%username%.%ext% :finish2 @echo usrpath=%usrpath%>>%computername%_%username%.%ext% @echo autpath=%autopath%>>%computername%_%username%.%ext% popd endlocal goto :EOF :usr if /i not "%line:~0,4%" EQU "path" goto :EOF set line=%line:;=#% for /f "Tokens=1,2*" %%j in ('@echo %line%') do set usrpath=%%l set usrpath=%usrpath:#=;% goto :EOF :auto if /i not "%line:~0,13%" EQU "Parseautoexec" goto :EOF for /f "Tokens=1,2*" %%j in ('@echo %line%') do set autoexec=%%l if not "%autoexec%" EQU "1" goto :EOF :auto1 if not exist c:\autoexec.bat goto :EOF for /f "Tokens=1* Delims

" %%j in ('type c:\autoexec.bat') do call :auto2 "%%j" "%%k" goto :EOF :auto2 if /i not %1 EQU "path" goto :EOF set wrk1=%2# set autopath=%wrk1:~1,256% set autopath=%autopath:"#=%