[THIN] message notifier

  • From: "IT Support" <it@xxxxxxxxxxxx>
  • To: <thin@xxxxxxxxxxxxx>
  • Date: Tue, 28 Mar 2006 14:11:54 +0100

Greetings list

 

We currently employ a VBS script to notify users about mundane stuff
like Server Reboots and sandwich rounds (see below) but have noticed
that this can spike CPU and memory usage with the trillions of net sends
that the script sends out....

 

Has anyone else found a more efficient way to net send users?

 

Please feel free to tear apart the script and pick holes =)

 

-------------------------- Script Below ----------------------------

sGroupName = "All Internal Users" 

sDomain = "CORPORATE DOMAIN NAME" 

sMessage = "Server will be rebooted in 5 mins, please save your work and
log out"

bForce = False 

On Error Resume Next 

Err.Clear 

Set oGroup = GetObject("WinNT://" & sDomain _ 

  & "/" & sGroupName & ",group") 

If Err.Number <> 0 Then 

  Err.Clear 

  Wscript.Echo "Unable to find group " & sGroupName 

  Wscript.Quit(1) 

End If 

On Error GoTo 0 

Set oShell = CreateObject("Wscript.Shell") 

nCount = 0 

nError = 0 

For Each oMember In oGroup.Members 

  nRC = oShell.Run("command /c net send "& oMember.Name & " " &
sMessage, 0, bForce) 

  If nRC = 0 Then 

    nCount = nCount + 1 

  Else 

    nError = nError + 1 

    Wscript.Echo "Message NOT sent to " & oMember.Name _ 

      & ", error code " & nRC 

  End If 

Next 

------------------------------------------------------------------------
--

 

Regards,

Jaime

 

Other related posts: