This is the script. Excuse me if there's some bad practice going on, I've only recently learned VBScript.
Set objADSystemInfo = CreateObject("ADSystemInfo")
Set objDomain = GetObject("WinNT://" & objADSystemInfo.DomainShortName)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Set objLocalWMI = GetObject("winmgmts:\\.\root\cimv2")
Set output = WScript.StdOut
strSAVinstallPath = "\SophosUpdate\CIDs\S000\SAVSCFXP\Setup.exe"
output.write "Searching for SophosUpdate share on network devices ..." & vbCRLF & vbCRLF
strSophosConsoleServer = ""
For Each item In objDomain
If item.Class = "Computer" Then
' The item is a Computer, so let's do something with it
strComputer = item.Name
' Is it pinging?
Set colPing = objLocalWMI.ExecQuery("SELECT * FROM Win32_PingStatus WHERE Address='" & strComputer & "'")
For Each pingresult In colPing
If pingresult.statuscode = 0 Then
' The host is online, so let's get the list of shared resources
output.write strComputer & " is online" & vbCRLF
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colShares = objWMI.ExecQuery("SELECT * FROM Win32_Share")
For Each share In colShares
' Is there a share called SophosUpdate?
If UCase(share.Name)="SOPHOSUPDATE" Then
filepresent = objFSO.FileExists("\\" & strComputer & strSAVinstallPath)
If filepresent = True Then
strSophosConsoleServer = strComputer
output.write "** Found Sophos installer share at \\" & strComputer & "\" & share.Name & " **" & vbCRLF
Else
output.write "SophosUpdate share exists but is not valid (expected \\" & strComputer & strSAVinstallPath & ")" & vbCRLF
End If
End If
Next
Else
output.write strComputer & " is offline" & vbCRLF
End If
Next
End If
' Have we found the Sophos server? If so, exit the loop
If strSophosConsoleServer <> "" Then
Exit For
End If
Next
' Error out if we know that we didn't find the Sophos server
If strSophosConsoleServer = "" Then
output.write "Sorry, I could not find the Sophos console server on this domain. There's no online computer with a share called SophosUpdate available."
WScript.Quit 1
End If
' If we get this far, we know where the Sophos server is - hurrah!
If objFSO.FileExists("\\" & strSophosConsoleServer & strSAVInstallPath) = False Then
output.write "The installer file does not exist at \\" & strSophosConsoleServer & strSAVInstallPath & vbCRLF
output.write "This can happen when the installer path is different to S000"
WScript.Quit 1
End If
output.writeline "Installing SAV from \\" & strSophosConsoleServer & strSAVinstallPath & " using the ORCHIDVISION account" & vbCRLF
' Launch the installer
strInstallString = "\\" & strServer & strSAVinstallPath & " -user " & objADSystemInfo.DomainShortName & "\username -pass password -mng yes"
Call objShell.Run(strInstallString,, True)