appautorun AutoRun property
Example
Return to Introduction  Previous page  Next page
Applies to
acAppAutoRun component  

Declaration
property AutoRun: Boolean;  

Description
The AutoRun property controls whether the application is able to be automatically restarted on Windows startup.  

How does it works?
If you set AutoRun property to True, acAppAutoRun will install or uninstall your program to/from the list of startup programs, in '\Software\Microsoft\Windows\CurrentVersion\Run' (or '\Software\Microsoft\Windows\CurrentVersion\RunOnce' if RunOnce property is True) registry key. RootKey can be HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE, dependently of RunFor setting.  
 
Every program installed with acAppAutoRun will have an Application.Title property value as name of registry key, and Application.ExeName + '/autorun' as value of registry key.  
 
tip When you switching the AutoRun property value, caption button state will be changed accordingly (autorun if True or autorun2 if False). Menu item in the system menu will be checked (if True) or unchecked if False.  

Notes
1. Design-time property value may be differ to run-time value. This value will be read from the system registry on program start. If your program was not installed to the registry, acAppAutoRun component will use value specified at design-time.  
 
If you would like to make the AutoRun always True on FIRST program startup, you can use the acAppStartCounter component. See an example for more details.  
 
2. When the acAppAutoRun installs the program to the startup list, it stores the line with '/autorun' command-line parameter, used to determinate whether the program has been started automatically on Windows startup, or manually by user (by another program). So, if the program was started automatically on Windows startup, it contains the ''/autorun' argument in the command-line + the OnAutoRun event occurs. Use the ParamStr(1) function to determinate how the program has been started programatically.  

See also
RunFor, RunOnce and MenuItem properties;  
OnAutoRun event.