Go Back   TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



WOL Laptop clients SMS 2003 VBScript - a script to help manage laptops with WOL for SMS.

Windows Server Help


Reply
 
Thread Tools Search this Thread
  #1  
Old 15-03-2007
CPL
 
Posts: n/a
WOL Laptop clients SMS 2003 VBScript - a script to help manage laptops with WOL for SMS.

Original source taken Rob Kuehfus from then mutlitlated a bit to run
on Windows 2003 as a schedueled background task for SMS 2003 to wake
up the Laptop clients. I've changed the product to wolcmd.exe as
wol.exe was a little buggy. Sorry about the header btw, if someone is
looking in google groups those are the keywords that I would use.

The original vbs prompted for a csv file to be loaded up. In this one
the csv file is called servermacs.csv and is located in c:\wol\.
It'll drop a log in there as well called servermacs.log.

The contents of the csv look like this:

====start
Server1,00:08:02:47:47:13,172.31.168.2
Server2,00:08:02:47:47:14,172.31.168.3
Server3,00:08:02:47:47:15,172.31.168.4
Server4,00:08:02:47:47:16,172.31.168.5
====end

The script that send the wol magic packet, then pings 60 seconds later
to make sure it's up, sleeps for ten minutes, send the magic packet
again. Do it 12 times. The Success of the WOL and the ping are
created and recorded in the log for post auditing (aka C.Y.A.)

Why? We had client laptops going to sleep on us during larger patch
and app deployments with SMS and I work for a cheap organization.
Therefore beg, borrow and steal a solution to make it go (Jordy!).

Hopefully this help saves someone some grief with laptops and SMS.

Cheers!

====Start of Script
'==========================================================================
'March 9th, 2007
'
'v0.4
'Added in ping test to check the availability of the server in
question
'the log the results in the servermacs.log
'
'and
'
'Added sleep for 10 minutes before doing the loop again
'
'and
'
'Using wolcmd.exe instead
'
'v0.3
'
'Pulled the user dialogue stuff as XP SP2 is nerfed security wise and
doesn't allow for
'user actions through ActiveX control mechanisms.
'
'v0.2
'Next step put in a ten minute sleeping loop to run magic packets for
2 hours,
'
'
'v0.1
'Prompts for the MAC address *.csv file, imports it and runs it.
'
' Format of the csv file must follow example:
'
' eg. Server1,00:08:02:47:47:13,172.31.168.2
' Server2,00:08:02:47:47:14,172.31.168.3
' Server3,00:08:02:47:47:15,172.31.168.4
' Server4,00:08:02:47:47:16,172.31.168.5
'
'
' All of the source, wol.exe, logs and csv files are contained in
' c:\wol\wol.exe
'
' wolcmd.exe can be found at http://www.depicus.com
'
'==========================================================================
Option Explicit
Dim CSVFile, LogFile, objFSO, ObjLog, objCSV, strServerInfo,
arrServerInfo, strWOLMAC
Dim strMac, oShell, objDialog, objPath
DIM engine

'
' The loop counts backwards from 12
' and executes the subs
'
For engine = 12 To 1 Step -1
WOLProcess
Checkifalive
Sleeptenminutes
Next



Sub WOLProcess()

Const ForReading = 1
LogFile = "C:\wol\servermacs.log"
CSVFile = "c:\wol\servermacs.csv"
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Create Log file
Set objLog = objFSO.createTextFile(LogFile, ForWriting)
objLog.WriteLine "beginning process " & Now

Set objCSV = objFSO.OpenTextFile(CSVFile, ForReading)
Do Until objCSV.AtEndOfStream
strServerInfo = objCSV.Readline
arrServerInfo = Split(strServerInfo,",",-1)
WScript.Echo "Server Name: " & arrServerInfo(0)
WScript.Echo "Mac Address: " & arrServerInfo(1)
WScript.Echo "IP Address: " & arrServerInfo(2)

strMac = arrServerInfo(1)

strWOLMAC = Replace(strMac, ":", "")
WScript.Echo "WOL Mac: " & strWOLMAC

Set oShell = WScript.CreateObject ("WSCript.shell")
ReturnCode = oShell.run("c:\wol\wolcmd.exe " & strWOLMAC)
WScript.Echo ReturnCode
' write to log file
If ReturnCode > 0 Then
ObjLog.WriteLine "Wake on Lan Failed on Server: " &
arrServerInfo(0) & " at Mac Address " & arrServerInfo(1)
Else
ObjLog.WriteLine "Wake on Lan Signal sent to Server: " &
arrServerInfo(0) & " at Mac Address " & arrServerInfo(1)
End If

Loop

objLog.WriteLine "Process completed at " & Now
objLog.Close
End Sub

'
' Ping in 60 seconds and write to the log if
' alive
'
Sub Checkifalive()

wscript.sleep 60000
Const ForReading = 1
LogFile = "C:\wol\servermacs.log"
CSVFile = "c:\wol\servermacs.csv"
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Create Log file
Set objLog = objFSO.createTextFile(LogFile, ForWriting)
objLog.WriteLine "beginning process " & Now

Set objCSV = objFSO.OpenTextFile(CSVFile, ForReading)
Do Until objCSV.AtEndOfStream
strServerInfo = objCSV.Readline
arrServerInfo = Split(strServerInfo,",",-1)
WScript.Echo "Server Name: " & arrServerInfo(0)
WScript.Echo "Mac Address: " & arrServerInfo(1)
WScript.Echo "IP Address: " & arrServerInfo(2)

strPING = arrServerInfo(2)
WScript.Echo "Ping IP: " & strPING

Set oShell = WScript.CreateObject ("WSCript.shell")
ReturnCode = oShell.run("ping.exe " & strPING)
WScript.Echo ReturnCode
' write to log file
If ReturnCode > 0 Then
ObjLog.WriteLine "Wake on Lan Failed on Server: " &
arrServerInfo(0) & " at IP Address " & arrServerInfo(2)
Else
ObjLog.WriteLine "Wake on Lan Signal sent to Server: " &
arrServerInfo(0) & " at IP Address " & arrServerInfo(2)
End If

Loop

End Sub

Sub Sleeptenminutes()

wscript.sleep 600000

End Sub
====End Script


Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Tags: , , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "WOL Laptop clients SMS 2003 VBScript - a script to help manage laptops with WOL for SMS."
Thread Thread Starter Forum Replies Last Post
How to manage outlook express in windows 2003 server. MicroDon Technology & Internet 4 26-11-2010 12:33 PM
Can Windows 2003 R2 Server manage Windows 7 Clients? Breckon Active Directory 3 24-03-2010 11:40 AM
We receive error code 0x8004011D on clients in Outlook 2003 Lupin Small Business Server 1 26-08-2009 07:21 PM
Can you change the default VPN port on server 2003 and XP clients? Just Guessing Windows Server Help 6 05-10-2007 10:31 AM


All times are GMT +5.5. The time now is 10:16 AM.