I thought I’d start 2010 with a blog posting pretty early on. I’ve had a blog for a few months, and only blogged a few times. I’m hoping this year I can get a few more done. Anyway, onto the blog…
Something I was trying to get my head around lately was how to do a reboot nag that displays a balloon, similar to Automatic Updates. This is something that could be fairly useful at the tail end of SMS packages etc. My first option of VBScript, as far as I know, doesn’t do notifications using balloons. I searched for other ways, and couldn't come up with anything, apart from a few “freeware” that looked a bit suspicious. Then I remembered AutoIT v3 - http://www.autoitscript.com/autoit3 which I’d used for some other scripts in the past. AutoIt, for those who are unfamiliar, is a scripting language that is more catered for handling things on the screen (moving windows, selecting items, typing characters, handling input etc.). Anyway, here’s the script I came up with:-
::::::::::::::
Nag.au3
::::::::::::::
;
; AutoIt Version: 3.0
; Language: English
; Platform: Win9x/NT
; Author: Tom Watson
;
; Script Function:
; Displays a balloon message to restart the system
;
TraySetIcon("mucltui.dll",3)
TraySetToolTip ("Please restart your system")
Break(0) ;Disable break
While 1 = 1
TrayTip("Global IT", "Critical updates have been installed on your system. Please save your work and restart your system as soon as possible.", 10, 1)
Sleep (55000)
WEnd
(Watch the word wrap). All this does is display a balloon for 5 seconds, and waits for another 55 seconds before redisplaying it in an infinite WHILE loop. It uses the Automatic Updates DLL for its icon, and if you hover over the icon while the balloon isn’t displayed, it displays a much shorter summary. You could modify this to suit your needs.
AutoIt has lots of functions you can use to display notifications, handle input etc. (see http://www.autoitscript.com/autoit3/docs/functions.htm for more details). Also, one of the things you can do with AutoIt is to compile your scripts into a .EXE, which is what you would normally do if using your script on other PCs. If you compiled the script above to an .EXE, you could launch it in a number of ways. e.g. from a .VBS script:-
::::::::::::::
Nag.vbs
::::::::::::::
Set objShell = CreateObject("Wscript.Shell")
strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
strFolder = objFSO.GetParentFolderName(objFile)
strPath = CHR(34) & strFolder & "\Nag.exe" & CHR(34)
objShell.Run strPath, 1, FALSE
Or even launch it remotely by using PSExec:-
D:\My AutoIt3 Scripts> psexec.exe -s -c -f -d -i \\pc65 Nag.exe
PsExec v1.97 - Execute processes remotely
Copyright (C) 2001-2009 Mark Russinovich
Sysinternals - www.sysinternals.com
Nag.exe started on pc65 with process ID 4644.
I hope this gives you some ideas for an alternative way to handle reboots, or even do other more complex tasks.