 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Ron1
Joined: 20 Dec 2007 Posts: 39 Location: United States of America
|
Posted: Sun Jul 20, 2008 9:27 pm Post subject: What is best way for AHK to detect when PC is done booting? |
|
|
In Windows XP (Service Pack 3), what is the best way for AHK to detect when a computer has finished booting?
Ideas to Date
Use the Task Manager (Ctrl+Alt+Del, and then the Processes tab) to find a file that always begins running as close to the end of the boot process as possible (and stays running), and then detect that file. The file wscntfy.exe (Windows Security Center Notification, introduced in WinXP Service Pack 2) seems to meet these requirements, so I am currently using the following script.
| Code: | DetectHiddenWindows, on ; since wscntfy.exe is a hidden file
IfWinExist, ahk_class SecNotify ; the ahk_class reported by AU3_Spy.exe
; when right clicking on the "shield" icon
; generated by wscntfy.exe in the System Tray
MsgBox Booting has finished. |
But is there a more generic way, and thus a better way, to do this? |
|
| Back to top |
|
 |
Thrillski
Joined: 18 Jul 2007 Posts: 65 Location: South Florida
|
Posted: Sun Jul 20, 2008 11:12 pm Post subject: Start Right |
|
|
Not sure if this is what you are looking for, but I have discovered this little utility, Start Right, which lets you manage what gets started up and all of that fun stuff. I'm sure you can use something that would determine when THIS program ends and then you'd have your answer.
http://www.joejoesoft.com/cms/showpage.php?cid=113
Hope this helps...
Have a nice day!
Thrillski |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6264
|
Posted: Mon Jul 21, 2008 2:35 am Post subject: |
|
|
Sean suggested me to monitor userinit.exe and I have been using it in my main script ever since:
_________________
 |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 666 Location: MN, USA
|
Posted: Mon Jul 21, 2008 2:48 am Post subject: |
|
|
Very nice. That is a handy tip. Sean is some sort of genius, isn't he?  _________________ http://autohotkey.net/~jaco0646/ |
|
| Back to top |
|
 |
Ron1
Joined: 20 Dec 2007 Posts: 39 Location: United States of America
|
Posted: Mon Jul 21, 2008 5:31 pm Post subject: |
|
|
Thrillski, SKAN, and jaco0646,
Thank you all for your very helpful suggestions. They prompted me to explore the boot process further, as least as it applies to Windows XP, Service Pack 3, running on a 3.0 GHz Intel Core 2 Duo PC.
After a zillion boots and careful monitoring of the rapid changes in the running Processes shown by the Windows Task Manager, I found that there were three processes that were "better" for determining the end of the boot process than the wscntfy.exe program that I suggested above. "Better" here means that these other processes occurred later in the boot sequence. Here are the details:
wscntfy.exe (computer's name) appears and remains: call this time = 0 seconds
userinit.exe (no name) disappears: time = 7 seconds
wuauclt.exe SYSTEM appears and remains: time = 34 seconds
wmiprvse.exe NETWORK SERVICE appears and remains: time = 35 seconds
Clearly, userinit.exe improved upon wscntfy.exe by providing a later point in the boot process. What surprised me was how VERY much later both wuauclt.exe and wmiprvse.exe appeared. And there was very little disk activity in the interval following the disappearance of userinit.exe and the appearance of wuauclt.exe and wmiprvse.exe, making it seem as if the boot process had ended much sooner than it had.
I do see the presence of userinit.exe on the Processes list of the Task Manager just as soon as I am able to trigger the Task Manager, so I assume that userinit.exe will start before any AHK script can do so. This may have been a factor in Sean's selection of userinit.exe.
Whether wuauclt.exe and wmiprvse.exe are as generic as userinit.exe, in the sense of always appearing, no matter what the version of Windows XP, I cannot say.
Since wmiprvse.exe was labeled "NETWORK SERVICE", and since wuauclt.exe apparently plays a role in updating software over the network, I did check to see if the time at which these two programs appeared differed when the network was turned off, compared to turned on. The times were unchanged within the limits of my ability to measure.
Again, my appreciation for your help.
Ron1 |
|
| Back to top |
|
 |
Ron1
Joined: 20 Dec 2007 Posts: 39 Location: United States of America
|
Posted: Mon Jul 21, 2008 5:41 pm Post subject: |
|
|
Thrillski,
I am intrigued by your suggestion of monitoring Start Right. I use a somewhat similar program called StartUp Cop Pro, from the PC Magazine Utilities. But, unlike Start Right, StartUp Cop Pro doesn't let the user determine the order in which the programs are to be started, as least as far as I have determined to date.
http://www.pcmag.com/article2/0,2817,2177188,00.asp
Ron1 |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 666 Location: MN, USA
|
Posted: Mon Jul 21, 2008 11:31 pm Post subject: |
|
|
wuauclt.exe is the Windows Update service, which doesn't appear if automatic updates are turned off (at least on my XP SP2 machines). I wouldn't depend on this service in any scripts you might distribute. Windows Update might be calling wmiprvse.exe (Windows Management Instrumentation) as well, which would explain it starting up right afterwards. _________________ http://autohotkey.net/~jaco0646/ |
|
| Back to top |
|
 |
Ron1
Joined: 20 Dec 2007 Posts: 39 Location: United States of America
|
Posted: Tue Jul 22, 2008 1:12 pm Post subject: |
|
|
jaco0646,
I share your concern about wuauclt.exe not being generic enough (and also wmiprvse.exe). Also, they require a very long wait, indeed, which I am questioning as necessary. So I have settled on using userinit.exe for the moment.
On my XP SP3 configuration, wuauclt.exe and wmiprvse.exe both execute on the boot, even though I do have automatic updates turned off in wscntfy.exe (thus the shield icon in the system tray is red with a white X in it, rather than green). So there may be a difference between XP SP2 and XP SP3, in this regard.
I could not find a way to detect the closing of userinit.exe with WinWaitClose, so I am using Process as shown below. But, with Process, I did get one instance of an odd blank screen, which puzzles me. So I am still on guard about using Process, even though this particular use seems benign. This is my first application of Process.
| Code: | Process, WaitClose, userinit.exe, 30 ; Wait 30 seconds for userinit.exe to close, then give up on waiting and proceed.
; Time from start of AHK script containing this line until userinit.exe closes is about 25 seconds on my particular system.
|
If one were concerned that the AHK script, set to execute on the boot, might start before userinit.exe starts, then one could use the following approach. But I haven't seen a need for the extra step so far. So I am assuming -- for the moment -- that userinit.exe will ALWAYS execute before any AHK script. But, hmmm, that one instance of a blank screen....
| Code: | Process, Wait, userinit.exe, 10 ; Wait 10 seconds for userinit.exe to exist, then give up on waiting and proceed.
Process, WaitClose, userinit.exe, 30 ; Wait 30 seconds for userinit.exe to close, then give up on waiting and proceed. |
I appreciate your comments.
Ron1 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|