StartUp, LogOn, LogOff, and ShutDown Scripts

Products and tips

Moderator: Site Mods

Post Reply
User avatar
Thracx
Silver Member
Silver Member
Posts: 263
Joined: 2004 Nov 05, 19:33
Contact:

StartUp, LogOn, LogOff, and ShutDown Scripts

Post by Thracx »

Windows (and other OSes) lets you run scripts when it starts or stops, or when a user logs on or off.  I use the StartUp & LogOn events to configure my RamDisk, but that's mainly for historical reasons (the RamDisk software I used to use didn't have a Windows Service option).

Does anybody use this feature, and if so, for what?
-Thracx

"Man wants to know, and when he ceases to do so, he is no longer a man."
-Fridtjof Nansen
Kilmatead
Platinum Member
Platinum Member
Posts: 4578
Joined: 2008 Sep 30, 06:52
Location: Dublin

Post by Kilmatead »

Tangentially, I remember once being frustrated by wanting to run certain things only upon Wakeup from Sleep (as opposed to Startup or Logon), and after lots of experimentation came up with this:

Code: Select all

Option Explicit

Dim wmiPowerManagementEvent, oShell
Const cntEventEnteringWakeup = 7

Set wmiPowerManagementEvent = GetObject("winmgmts:").ExecNotificationQuery("Select * from Win32_PowerManagementEvent")
Do
   If wmiPowerManagementEvent.NextEvent.EventType = cntEventEnteringWakeup Then
      set oShell=createobject("WScript.Shell")
      oShell.Run """" + "{Insert Programme to Run on Wakeup Here}" + """"
   End If
Loop
Effectively used as a means of (for example) forcing (permanently running) email-clients to check for mail immediately upon wakeup, rather than waiting for their normal timeout cycle to reoccur... which could be any number of minutes, depending on when the computer was put to sleep (humanely) in the first place.

I'm not sure if the task scheduler allows for this now in an easier form or not (it never used to)... but I had more fun figuring out how to do it manually rather than actually having a practical purpose for it at the time.  (I'm easily amused. :wink:)
User avatar
Thracx
Silver Member
Silver Member
Posts: 263
Joined: 2004 Nov 05, 19:33
Contact:

Post by Thracx »

Kilmatead wrote:...upon Wakeup from Sleep...
Nice, might come in handy sometime with my HTPC - thanks!
Kilmatead wrote:...but I had more fun figuring out how to do it manually rather than actually having a practical purpose for it at the time.  (I'm easily amused. :wink:)
And behold - you've discovered the Meaning of Life!!!   8)

(Seriously - enjoying while learning, one of the best uses of time!)
-Thracx

"Man wants to know, and when he ceases to do so, he is no longer a man."
-Fridtjof Nansen
Post Reply