The steps outlined below would help you with three things:
- Autologon to a system with a particular account
- Send a notification mail when that account is logged in to the system after a reboot
- Lock the system automatically once the account has been logged on
Step 1 - Enable Autologon:
- Go to Start > Run and put "regedit.exe" and click "Ok"
- Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon in Registry Editor
- Change the REG_SZ "DefaultUserName" value to the username you want to autologon to the system
- Change the REG_SZ "DefaultPassword" value to the password of the user you want to autologon to the system. (If the key does not exist then do create it)
- Change the REG_SZ "DefaultdomainName" value to the domain name you wish to logon to (If the key does not exist then do create it)
- Add a new REG_SZ "AutoAdminLogon" and set the value to 1
- Close Registry editor
Step 2 - Prepare notification files:
- Create a directory C:\Autologon;
- Create the files chkLogtime.vbs, Locksystem.cmd and Delchklog.cmd with the contents mentioned in Annexure I below
Step 3 - Setup up notification and autolock:
- Go to Start > Run and put "regedit.exe" and click "Ok"
- Navigate to HKEY_USERS\<SID of particular user>\software\Microsoft\Windows\CurrentVersion\Run in Registry Editor
- Add a new REG_SZ "ChkLogtime" and set the value to C:\Autologon\ChkLogtime.vbs
- Add a new REG_SZ "LockSystem" and set the value to C:\Autologon\Locksystem.cmd
Step 4 - Enable notification:
- Open Group Policy Object Editor
- Navigate to Local Computer Policy\Computer Configuration\Windows Settings\Scripts\ (Startup/shutdown)
- Double click on Shutdown in the right hand pane
- Click Add and Browse to the file C:\Autologon\Delchklog.cmd
- Click OK twice and close Group Policy Object Editor
NOTES:
- The Autologon would not work if the LegalNotice warning window is enabled at the domain level. You might have to do additional configuration to disable this.
- Automatic reboots will not work unless you specify ‘/F’ switch in your reboot script.
Annexure I
ChkLogTime.vbs
Dim WShell,SrvName
Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject")
Set WShell = WScript.CreateObject("WScript.Shell")
If objFSO.FileExists("C:\Autologon\ChkLogTimeskip.txt") Then
wscript.Quit
Else
Set objFile = objFSO.CreateTextFile("C:\Autologon\ChkLogTimeskip.txt")
SrvName = Trim(WShell.ExpandEnvironmentStrings("%COMPUTERNAME%"))
User=Trim(WShell.ExpandEnvironmentStrings("%USERNAME%"))
LogTime= User &" is successfully logged onto " & SrvName &" after scheduled reboot at "& Now
objFile.writeline LogTime
objfile.close
Call SendMailAlerts(LogTime, User, SrvName)
End IF
Wscript.Quit
#################### Send Email Alerts ########################
Function SendMailAlerts(LogTime, User, SrvName)
RecipientList ="mukulag@gmail.com"
smtpsrv = "smtp.mukulag.com"
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "MyServer@mukulag.com"
objEmail.To = RecipientList
objEmail.Subject = User & " has logged on succesfully to " & SrvName " at " & Now
objEmail.TextBody = LogTime
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpsrv
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
End Function
'##################### End Send Email Alerts ###########################
Locksystem.cmd
rundll32.exe user32.dll, LockWorkStation
DelChkLog.cmd
Del C:\Autologon\ChkLogTimeskip.txt /F
-------------- End of Document -----------------
Tags: Windows Server 2003
Published Date: 20071207