how would i run the application as soon as the user starts their computer?
Printable View
how would i run the application as soon as the user starts their computer?
Put a shortcut in the startup. This can be done during setup. It should be in your deployment wizard and if it's not, change what you use to create your setup files.
You could either put a shortcut to your program in the Startup folder in the start menu, or you could use the registry hereCode:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
Heh, beat me to it :D
lpeek, please stop asking your questions in new threads when they have already been answered in other threads. This is both rude and annoying. If something doesn't get fully answered, bump your old thread. Do not create a new one. That adds clutter to the boards.
If you wanna do it via code...
In a module:
VB Code:
Option Explicit Public Const REG_SZ = 1 Public Const HKEY_CURRENT_USER = &H80000001 Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long Public Sub SaveSettingString(hKey As Long, strPath As String, strValue As String, strData As String) Dim hCurKey As Long Dim lRegResult As Long lRegResult = RegCreateKey(hKey, strPath, hCurKey) lRegResult = RegSetValueEx(hCurKey, strValue, 0, REG_SZ, ByVal strData, Len(strData)) lRegResult = RegCloseKey(hCurKey) End Sub
In your form:
VB Code:
Private Sub Form_Load() Dim sAppEXE As String sAppEXE = App.Path & IIf(Right$(App.Path, 1) = "\", "", "\") & App.EXEName & ".exe" SaveSettingString HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Run", App.Title, Chr$(34) & sAppEXE & Chr$(34) End Sub
There's an API method of returning the exact executeable path\filename of an application and it's more robust than the method I used so I recommened it if you've got the time.
-adehh
the bits that say:
Public Const REG_SZ = 1
Public Const HKEY_CURRENT_USER = &H80000001
Are in red and say:
Constants are not allowed as public members of object modules
10 aussie dollars that you didn't put that portion of code in a Module like adzzzz said :)
If there in a Form - use Private!
Bruce.
Hold on a second. Are you asking how to start an app when Windows loads up, or when the computer is turned on?