Jump to content
Sign in to follow this  
maqleod

Toggle start with Windows

Recommended Posts

maqleod

I use this in many of my scripts, a nice simple way to toggle whether or not your script starts with Windows.

#include <GUIConstants.au3>

$parent = GUICreate("test",195,175,-1,-1,-1,-1)

$fileopt = GUICtrlCreateMenu("&File")
$startonboot = GUICtrlCreateMenuItem ("Start On Boot",$fileopt)
$reg = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Test")
if $reg = @ScriptFullPath then
GUICtrlSetState(-1,$GUI_CHECKED)
elseif $reg <> @ScriptFullPath then
GUICtrlSetState(-1,$GUI_UNCHECKED)
endif

GUISetState()
Do
$msg = GUIGetMsg()

if $msg = $startonboot then
if BitAnd(GUICtrlRead($startonboot),$GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($startonboot,$GUI_UNCHECKED)
RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Test")
else
GUICtrlSetState($startonboot,$GUI_CHECKED)
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Test", "REG_SZ", @ScriptFullPath)
endif
endif

Until $msg = $GUI_EVENT_CLOSE
GUIDelete()

[u]You can download my projects at:[/u] Pulsar Software

Share this post


Link to post
Share on other sites
star2

thank u for telling me what is the registry key to start programs on boot

nice job


[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

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  

×