Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Windows logon script, run macro (exe) when pc fully booted
#1
In my logon script I have a shortcut to macro (converted to .exe) and as soon as I logon that .exe is executed.

The line that runs the macro.exe is in the logon script looks like this
Code:
Copy      Help
.
.
START "" "F:\PortableApps\macro.exe"
.
.

It is a line within a batch file (.bat) that runs as soon the user logs on.
I created a shortcut from that batchfile to the "startup" folder (also reachable through 'START-menu')
C:\Users\*USERNAME*\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

My question

I want something in the code of the macro that first waits when windows is fully loaded.
Or at least when all systray items are loaded/present.

Code:
Copy      Help
...[ code that waits on pc to be fully loaded]
or
...[ code that waits on all systray items to be loaded]

...[actual macro code]

Is it possible to do this in QM, I have no idea what process/item QM could 'wait' for that indicates a fully booted pc.
It doesn't have to be exact at "fully booted" state maybe there is an trigger I could "wait" for that signals that the pc almost fully booted?
(as an example I gave: wait for all systray items rendered?)

Is this possible?
#2
I think there are no reliable ways to know when Windows and startup programs/services are fully loaded. Also, depends on what must be loaded/working. Is it when Windows becomes quiet and responsive, or when you can access network files, internet, or when certain process is loaded, etc.

For me, the main indicator that Windows is still loading is disk activity. This code waits while disk is busy.
Code:
Copy      Help
int n d=GetDiskUsage
;int c=GetCPU
rep
,1
,d=GetDiskUsage
,out d
,;out "%-5i %5i" d GetCPU
,if(d<=5)
,,n+2
,,if(n>=10) break
,else if(n>0) n-1
GetDiskUsage uses performance counters. On some Windows versions it does not work if the macro runs not as administrator.
This code may wait too long if something uses disk after Windows is fully loaded, for example some Windows service or antivirus. Try to replace 5 to 20 or 50. Waiting for CPU is less reliable. Maybe better simply use wait 10 or wait 20 etc, depending on your PC startup speed.

To wait for a tray icon, wait for its accessible object.
Code:
Copy      Help
int w=wait(60 WV win("" "Shell_TrayWnd"))
Acc a.Find(w "PUSHBUTTON" "QTranslate 4.1.0" "class=ToolbarWindow32[]id=1504" 0x1005 60)

See also:
http://stackoverflow.com/questions/1050 ... er-startup
#3
Thank you!, i can work with this!


Forum Jump:


Users browsing this thread: 1 Guest(s)