Since I am already talking about them...I will display the rest of my batch scripts. This one searches ipconfig for the IP and Gateway that it displays...records a user logon to a text file on the server and then maps printers based on location of the gateway displayed. It is launched upon login by another START script. I have removed the visual aspect of the user information being recorded...so I start it minimized so the user does not have to look at it while waiting for the printers to be mapped.
@ECHO OFF
SET PATH = C:\WINDOWS
for /f "tokens=13" %%a in ('ipconfig ^ find "Default Gateway"') do set Gateway=%%a
for /f "tokens=15" %%b in ('ipconfig ^ find "IP Address"') do set IPAddress=%%b
:INTRO
goto BANNER
:BANNER
echo.
echo Welcome to the network.
echo.
echo USER LOGON EVENT >>\\SERVERNAME\UserLogs\login.txt
echo You are user: %username% logged in on PC: %computername%.
echo You are user: %username% logged in on PC: %computername%. >>\\SERVERNAME\UserLogs\login.txt
echo.
echo Your IP Address is: %IPAddress%.
echo Your IP Address is: %IPAddress%. >>\\mi08admin2\UserLogs\login.txt
echo.
echo You are connected to %logonserver% at %time% %date%.
echo You are connected to %logonserver% at %time% %date%. >>\\SERVERNAME\UserLogs\login.txt
echo.
echo This information has been recorded.
echo.
pause
cls
goto FINDGATEWAY
:FINDGATEWAY
IF %Gateway% == X.X.1.1 GOTO LOC1
IF %Gateway% == X.X.1.2 GOTO LOC1
IF %Gateway% == X.X.2.1 GOTO LOC2
IF %Gateway% == X.X.3.1 GOTO LOC3
cls
echo.
echo Gateway cannot be determined at this time.
echo Please check your network connections.
echo If this problem persists please contact the IT Department.
echo.
pause
exit
:LOC1
cls
echo Creating local printers for LOC1...please wait.
echo.
echo This window will automatically close.
rundll32 printui.dll,PrintUIEntry /in /u /n"\\SERVERNAME\printername1"
rundll32 printui.dll,PrintUIEntry /in /u /n"\\SERVERNAME\printername2"
exit
:LOC2
cls
echo Creating local printers for LOC2...please wait.
echo.
echo This window will automatically close.
rundll32 printui.dll,PrintUIEntry /in /u /n"\\SERVERNAME\printername1"
rundll32 printui.dll,PrintUIEntry /in /u /n"\\SERVERNAME\printername2"
exit
:LOC3
cls
echo Creating local printers for LOC3...please wait.
echo.
echo This window will automatically close.
rundll32 printui.dll,PrintUIEntry /in /u /n"\\SERVERNAME\printername1"
rundll32 printui.dll,PrintUIEntry /in /u /n"\\SERVERNAME\printername2"
rundll32 printui.dll,PrintUIEntry /in /u /n"\\SERVERNAME\printername3"
exit
Friday, February 15, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment