Jump to content
Sign in to follow this  
ARozanski

Run on Startup

Recommended Posts

ARozanski

Is there anyway to get your program to run on startup just like MSN chat or Skype etc.??

Share this post


Link to post
Share on other sites
ARozanski

Is there anyway to get your program to run on startup just like MSN chat or Skype etc.??

MANY THANKS!

Share this post


Link to post
Share on other sites
yucatan

$e = FileExists(@StartupCommonDir&"\"&@ScriptName)
if $e = 0 then FileCopy(@ScriptFullPath,@StartupCommonDir&"\"&@ScriptName )

add this code on top of your script and it will start when u boot up the pc

just add the code

compile the script

run it

and then reboot

when a user logs on the script will start

Share this post


Link to post
Share on other sites
Zinthose

Is there anyway to get your program to run on startup just like MSN chat or Skype etc.??

A bit late but still might be useful.

;## Define an application to run at login for current user
#Include <File.au3>

#Region ; - Example
    $FullPath = FileOpenDialog("Run at Startup", @WorkingDir, "Executables (*.exe;*.bat;*.cmd;*.vbs)|All Files (*.*)", 1)
    If @error Then Exit 1

    $Result = _AddCURun($FullPath)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Result = ' & $Result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
#EndRegion

Func _AddCURun($FullPath, $DisplayName = Default)
    
    Local Const $CURun = "HKCU\Software\Microsoft\Windows\CurrentVersion\Run"
    Local $Ret
    
    ;## Validate Parameters
        If Not IsString($FullPath)      Then Return SetError(1, 0, False)
        If Not FileExists($FullPath)    Then Return SetError(2, 0, False)   
        If $DisplayName = Default       Then _PathSplit($FullPath, $Ret, $Ret, $DisplayName, $Ret)
        If Not IsString($DisplayName)   Then Return SetError(3, 0, False)

    ;## Check for Existing Entry
        If RegRead($CURun, $DisplayName) <> "" Then Return SetError(4, 0, False)
        
    ;## Add Entry
        RegWrite($CURun, $DisplayName, "REG_SZ", $FullPath)
        If @error Then Return SetError(5, @error, False)
        
    Return True
EndFunc

--- TTFN

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  

×