I was recently approached by one of my colleagues with a dilema, he had to go round our 30+ servers and stop and start a couple of Sophos’s Windows Services.
Now, as you can imagine this was starting to look like a fairly large and mundane task. Which is when I came up with this little VBScript.
Using this script below, you can pass it a text file with a list of machines you would like it to perform the process on.
In the script below you will see a “” change this to your text file containing machines, full file path.
The format of the text file is one machine per line.
This script is by no means ‘bullet proof’ and could be enhanced easily with little time and effort. It could also be modfied to stop\start any services you like.
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("", ForReading)
Do Until objTextFile.AtEndOfStream
strComputer = objTextFile.Readline
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='Sophos Message Router'")
For Each objService in colServiceList
errReturn = objService.StopService()
WScript.Echo errReturn
Next
Wscript.Sleep 20000
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='Sophos Message Router'")
For Each objService in colServiceList
errReturn = objService.StartService()
WScript.Echo errReturn
Next
Loop
Active directory can be a bit of a beast if not managed and maintained correctly. Using this code in a .vbs file you can output all currently disabled accounts.
You may want to expand this by using the file system object to output to a file?
Const ADS_UF_ACCOUNTDISABLE = 2
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
";(objectCategory=User)" & _
";userAccountControl,distinguishedName;subtree"
Set objRecordSet = objCommand.Execute
intCounter = 0
Do Until objRecordset.EOF
Hello, Just a quick post to inform you all that my simple reset app for Windows Mobile 6 has now been repackaged into it’s own CAB file and now supports Modaco’s AppToDate
You can download RSReset from the downloads section, and read more about it on it’s project page
If you don’t yet have AppToDate on your mobile device you can download it from Modaco
Thanks
Use this simple VB.NET code to convert bytes to MB’s, GB’s etc. Handy for returning sizes of files/folders
Function ConvertSize(Size)
Do While InStr(Size,",") 'Remove commas from size
CommaLocate = InStr(Size,",")
Size = Mid(Size,1,CommaLocate - 1) & _
Mid(Size,CommaLocate + 1,Len(Size) - CommaLocate)
Loop</p> <p>Suffix = " Bytes"
If Size >= 1024 Then suffix = " KB"
If Size >= 1048576 Then suffix = " MB"
If Size >= 1073741824 Then suffix = " GB"
If Size >= 1099511627776 Then suffix = " TB"
Select Case Suffix
Case " KB" Size = Round(Size / 1024, 1)
Case " MB" Size = Round(Size / 1048576, 1)
Case " GB" Size = Round(Size / 1073741824, 1)
Case " TB" Size = Round(Size / 1099511627776, 1)
End Select
ConvertSize = Size & Suffix
End Function







