Sign in to follow this  
Followers 0
EndFunc

Execute scirpt after desktop loads

8 posts in this topic

#1 ·  Posted (edited)

Ok,I've been trying to execute a script after you login to windows. Problem is when I do it using RunOnce registry settings it halts windows from loading the desktop until the script is executed. Normally thats not an issue but I need the desktop to load so that a window will open to finish an installation that required a reboot.

I guess I could use a timer but either way it will halt the desktop from loading so I'm kind of stuck on how to get it run afterwards. If I don't put it in the RunOnce it won't execute at all on login. :)

Any good suggestions?

TIA

Edited by EndFunc

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites



Why not use a RUN registry entry in stead of RUNONCE?

Jos

Because I believe Run will execute everytime you login. I only need it to do it one time and that's it. Also not sure if Run will still wait for the script to run before loading the desktop still. Unless I delete the key after it does what it needs to. However I still don't know if Run will wait for the desktop to load like RunOnce does.


EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

Because I believe Run will execute everytime you login. I only need it to do it one time and that's it. Also not sure if Run will still wait for the script to run before loading the desktop still. Unless I delete the key after it does what it needs to. However I still don't know if Run will wait for the desktop to load like RunOnce does.

The times I ve done this was indeed using RUN and removing the Registry entry as first thing in the script and then Sleep() for a while to ensure the desktop was loaded and all services started.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

The times I ve done this was indeed using RUN and removing the Registry entry as first thing in the script and then Sleep() for a while to ensure the desktop was loaded and all services started.

Jos

Yes I should have remembered that RUN will load the desktop due to all the programs I have that start while windows loads. DUH..lol but was trying to use the "correct" method rather than add and deleting keys, but if it works then who cares right? :) Thanks


EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

First time poster, long time watcher. Does anyone have any examples to accomplish this in W7.

I have the same issue as the OP & is really bugging me.

Cheers

MC

Share this post


Link to post
Share on other sites

Hi maverickschoice,

The HKLM RunOnce key will halt loading the Desktop until the data entries complete.

The HKCU RunOnce key will continue loading the Desktop while processing the data entries.

An example using the HKCU RunOnce key

If Not @Compiled Then
    ; not compiled script will exit
    MsgBox(0, @ScriptName, 'Compile this script to test')
    Exit
ElseIf Not $CMDLINE[0] Then
    ; add registry entry to run once the compiled script
    If RegWrite('HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce', _
            'test', 'REG_SZ', '"' & @ScriptFullPath & '" /restart') Then
        MsgBox(0, @ScriptName, 'This script has been added to the HKCU RunOnce key in the registry')
    EndIf
ElseIf $CMDLINE[1] = '/restart' Then
    ; show msgbox which blocks and wait for desktop to load
    MsgBox(0, @ScriptName, 'Wait for the desktop to finish loading and then click OK')
EndIf
Compile the script. Run the compiled script and then reboot the PC to see the result. :huh2:

Share this post


Link to post
Share on other sites

Hi maverickschoice,

The HKLM RunOnce key will halt loading the Desktop until the data entries complete.

The HKCU RunOnce key will continue loading the Desktop while processing the data entries.

An example using the HKCU RunOnce key

If Not @Compiled Then
    ; not compiled script will exit
    MsgBox(0, @ScriptName, 'Compile this script to test')
    Exit
ElseIf Not $CMDLINE[0] Then
    ; add registry entry to run once the compiled script
    If RegWrite('HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce', _
            'test', 'REG_SZ', '"' & @ScriptFullPath & '" /restart') Then
        MsgBox(0, @ScriptName, 'This script has been added to the HKCU RunOnce key in the registry')
    EndIf
ElseIf $CMDLINE[1] = '/restart' Then
    ; show msgbox which blocks and wait for desktop to load
    MsgBox(0, @ScriptName, 'Wait for the desktop to finish loading and then click OK')
EndIf
Compile the script. Run the compiled script and then reboot the PC to see the result. :huh2:

Thanks for that explanation, had a decent Google for an answer but you have nailed for me.

Cheers

MC

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0