Stop and Start Sophos services remotely

On September 20, 2011, in Blog, Programming, by Mike Hudson

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
Tagged with:  

Traverse disabled AD Accounts – VBScript

On June 21, 2011, in Programming, by Mike Hudson

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
Tagged with:  

FIRST PUBLIC RELEASE: RAPId SMS

On January 11, 2009, in BETA Releases, by Mike Hudson

Here’s my latest application.. A handy little app to send SMS messages to any mobile number via an activesync connected mobile phone! No third parties involved. No messy sms2email facilities.. This simply uses RAPI controls and WM6 SDK API’s to send a message to an active sync connected device, and the fire it off to the specified recipient.

Features:

  • Quick and easy way to send txt messages without having to pick up your phone
  • Ability to storesend template messages on a schedule or at the click of a mouse button

Version History

1.0.0.0 – First BETA released, no known bugs, many updates to come!
1.0.0.2 – Second BETA released, added many GUI updates, added Modaco AppToDate support.
1.0.0.3 – Third BETA released, this one’s public! You can download the desktop setup program here, once downloaded click File > Install on Device to install the device side application.

You can download the desktop setup program here

If you are having problems with this application please post a message in the forum

Tagged with:  

Really Simple Reset Repackaged

On January 3, 2009, in Blog, by Mike Hudson

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

Tagged with:  

File size calculator

On January 2, 2009, in Programming, by Mike Hudson

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
Tagged with:  

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!