#76312 - 2003-08-09 11:46 PM
Wake-on-LAN combined with SUS, using KiXtart scripts
|
Eduard
Fresh Scripter
Registered: 2003-08-09
Posts: 16
Loc: Amsterdam
|
Hi,
At our office, we are using Microsoft’s SUS-server (Software Update Services), which automatically employs critical and security updates to Windows 2000 client PC’s. The common setup of SUS often requires users to reboot their PC a few minutes after starting-up, which can be an annoyance when they are busy. Therefore I figured out how to use SUS in combination with a Wake-on-LAN function. For this, I made two KiXtart scripts. Both because some of you might be interested in how I did set this up, and because I (still being a novice regarding scripting) would be interested in any suggestions for improvements, I am posting these scripts in this forum. For a complete story of how I did set this up, please take a look at the following homepage: http://www.gironet.nl/home/evbalen/index.htm
The scripts are running under KiXtart version 4.21 This are the two scripts:
sustatus.kix
code:
;This script checks for the status of SUS Auto Update on shutdown, ;sets the WOL-trigger in a daily log file, taking into account weekends, ;and writes the AU-status to a log file. IF @WDAYNO > 4 $Day = @YDAYNO + 8 - @WDAYNO ELSE $Day = @YDAYNO + 1 ENDIF $AUState = READVALUE("HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update","AUState") IF $AUState = 5 OPEN(1,"\\server-name\WOL$\" + @YEAR + $Day + ".log",5) WRITELINE(1, @IPADDRESS0 + "," + @ADDRESS + @CRLF) ENDIF OPEN(2,"\\server-name\WOL$\sustat.log",5) WRITELINE(2, @DATE + "," + @TIME + "," + $AUState + "," + @IPADDRESS0 + "," + @WKSTA + @CRLF)
The result of this script is a daily log file, named like "yearday.log" (for example 2003203.log). These logs contain a list of computers that have to be started at that day. It is in the form: "IP-address,MAC-address" on each line. "$Day" is a variable that ensures that no startups are scheduled on Saturdays or Sundays. "WOL$" is a share on the server where the logs are stored. Note that, because the local system account runs the script at shutdown, this share has to be read/write accessible to "Everyone". "sustat.log" is an optional additional log file to log the status of every computer at every shutdown.
wol.kix
code:
;This script reads the daily log file for today, ;starts the respective PC's, and logs this action. OPEN(1,"\\server-name\WOL$\suswol.log",5) IF OPEN(2,"\\server-name\WOL$\" + @YEAR + @YDAYNO + ".log",2) = 0 $PC = READLINE(2) WHILE @ERROR = 0 $MAC = RIGHT($PC,12) $IP = VAL(LEFT(RIGHT($PC,16),3)) RUN "poweroff.exe wol -ip 192.168.0.$IP -subnet 255.255.255.0 -mac $MAC" WRITELINE(1, @DATE + "," + @TIME + "," + $PC + @CRLF) SLEEP 1 $PC = READLINE(2) LOOP ENDIF
The result of this script is, that all computers that are listed in the daily log file for today, are sent a magic packet by PowerOff, to initiate a Wake-on-LAN. "suswol.log" is an optional additional log file to log all Wake-on-LAN instances. "$PC" is a variable containing a line from the daily log file. "$MAC" is a variable containing the computer’s MAC-address. "$IP" is a variable containing the last octet of the computer’s IP-address. The SLEEP function ensures that not all computers are started at the same moment, to preclude a sudden peak in power consumption.
Any thoughts about this?
Thanks,
Ed
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 778 anonymous users online.
|
|
|