If you have commands in your logon script that only need to run when the script changes, use the following technique to cause it to only run when the script has changed.

Example:

@echo off                              setlocal                              net use x: \\ServerName\ShareName1                              net use y: \\ServerName\ShareName2                              rundll32 printui.dll,PrintUIEntry /ia /c\\PRTSVR /m "AGFA-AccuSet v52.3" /h "Intel"                              rundll32 printui.dll,PrintUIEntry /if /b "Test Printer" /c\\PRTSVR /f "%windir%\inf\ntprint.inf" /r "lpt1:" /m "AGFA-AccuSet v52.3"                              endlocal                              If you only wanted the rundll32 commands to run when the script has changed:                              @echo off                              setlocal                              net use x: \\ServerName\ShareName1                              net use y: \\ServerName\ShareName2                              :: Insert                              :: set batchdp to the full path to the script file.                              set batchdp="%~f0"                              :: set batchfn to the file name of the script file.                              set batchfn=%~n0                              :: set batchfnx to the file name and extension of the script file.                              set batchfnx=%~nx0                              :: set oldfile to the file name that records the script date / time in the user's profile                              set oldfile="%userprofile%\%batchfn%.old"                              If not exist %oldfile% set old=none&goto postit                              :: Retrieve the previous script date / time                              for /f "Tokens=*" %%a in ('type %oldfile%') do (                               set old=%%a                              )                              :postit                              :: Set the current script date / time                              for /f "Tokens=*" %%a in ('dir %batchdp% /N^|findstr /L /I /c:"%batchfnx%"') do (                               set new=%%a                              )                              :: If the script has not changed, exit or goto .....                              if "%old%"=="%new%" endlocal&goto :EOF                              :: Write the current script's date / time to the user profile                              echo %new%>%oldfile%                              :: Previous code here                              rundll32 printui.dll,PrintUIEntry /ia /c\\PRTSVR /m "AGFA-AccuSet v52.3" /h "Intel"                              rundll32 printui.dll,PrintUIEntry /if /b "Test Printer" /c\\PRTSVR /f "%windir%\inf\ntprint.inf" /r "lpt1:" /m "AGFA-AccuSet v52.3"                              endlocal