hi, i have a vb program that monitors the time users log in and off, i have it start up in the start up but it only starts up when my account logs in (windows saved my preferences) how can i have it start up using vb with all users?
Printable View
hi, i have a vb program that monitors the time users log in and off, i have it start up in the start up but it only starts up when my account logs in (windows saved my preferences) how can i have it start up using vb with all users?
2 Ways I can think of:Quote:
Originally Posted by dark_shadow
1: Alter the registry and do it through there.
2. Add a shortcut to your program in the All Users >> StartUp folder :)
Cheers, Hope that helps
RyanJ
To alter the Registry add a string to this key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
You can name the string to whatever you like and it should contain the path to your application.
VB Code:
so how bout this? Private 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 Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long Const REG_SZ = 1 Const HKEY_CURRENT_USER = &H80000001 Const REGKEY = "Software\Microsoft\Windows\CurrentVersion\Run" Const KEY_WRITE = &H20006 Dim Path As Long Private Sub Form_Load() If RegOpenKeyEx(HKEY_CURRENT_USER, REGKEY, 0, KEY_WRITE, Path) Then Exit Sub Else RegSetValueEx Path, App.Title, 0, REG_SZ, ByVal App.Path & "\" & App.EXEName & ".exe", Len(App.Path & "\" & App.EXEName & ".exe") end sub
If you want it for all users change HKEY_CURRENT_USER to HKEY_LOCAL_MACHINEVB Code:
Private Const HKEY_LOCAL_MACHINE As Long = &H80000002