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%"<h1><a name="_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 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%"</a></h1>"" 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%"<h1><a name="_goto_finish1_set_ext_log_echo_syspath_syspath_gt_computername___username_log_goto_finish2_finish1_echo_syspath_syspath_gt_gt_computername___username_ext_finish2_echo_usrpath_usrpath_gt_gt_computername___username_ext_echo_autpath_autopath_gt_gt_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">"" 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</a></h1>" %%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:"#=%