Posts

Showing posts from 2008

Batch command to change DNS

cd\ netsh int ip set dns "local area connection" static 10।120.135.100 primary 'Add primary DNS netsh int ip add dns "local area connection" 10.4.148.103 'Add secondary DNS netsh int ip add dns "local area connection" 10.120.135.101 'Add additional DNS

Script to remove domain user from local administrator group

' (This script can run as logon script without problems because it first check if the user is a member. ' If the user is a local administrator s/he has privileges to remove him/her self from the local group. ' Do Keep in mind however that the user at this stage already is logged-on as an Administrator, ' s/he will keep all the access rights until the next logon). Set objNetwork = CreateObject("Wscript.Network") strUser = objNetwork.UserName strDomain = objNetwork.UserDomain strComputer = objNetwork.ComputerName strLocalGroup = "Administrators" On Error Resume Next ' Bind to local group object. Set objGroup = GetObject("WinNT://" _ & strComputer & "/" & strLocalGroup & ",group") If (Err.Number <> 0) Then wscript.Quit ' Bind to the user object on the Domain. ' (use also the WinNT provider). Set objUser = GetObject("WinNT://" _ & strDomain & "/&qu

Windows Service monitoring and mail reporting Scripts

Create following two files and modify accordingly as per your requirement. Create a scheduled batch file to execute. File name Service Test.bat Set Location as C:\ --------- c:\ date /t >C:\PortsReport.txt time /t >>C:\PortsReport.txt portQry -n Server name -e 25 >>C:\PortsReport.txt portQry -n Server name -e 110 >>C:\PortsReport.txt portQry -n Server name -e 80 >>C:\PortsReport.txt set /A STATUS = 0For /F " eol=; delims=: tokens=3" %%I in (' Find /I /C "NOT LISTENING"C:\PortsReport.txt') Do Set status=%%I if /I %STATUS% gtr 0 cscript C:\Errormail.vbs ----- File Name ErrorMail.vbs Set Location as C:\ ---- Set objMessage = CreateObject("CDO.Message") objMessage.Subject = "Server Protocol Status Report" objMessage.From = "" objMessage.To = "" objMessage।TextBody = "" objMessage.AddAttachment "C:\PortsReport.txt" objMessage.Configuration.Fields.Item _(" http://schemas.mi