programmer1024
Member
- Joined
- Jun 18, 2006
- Messages
- 23
- Programming Experience
- 3-5
Hi, how can I have my application start when they log on to Windows?
'add reference to COM "Windows Script Host Object Library" first
Dim shell As New IWshRuntimeLibrary.WshShell
Dim startupPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup)
Dim x As IWshRuntimeLibrary.WshShortcut
x = DirectCast(shell.CreateShortcut(startupPath & "\calc shortcut.lnk"), IWshRuntimeLibrary.WshShortcut)
x.Description = "Calculator"
x.TargetPath = "calc.exe"
x.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.System)
x.Save()
Dim regpath As String = "Software\Microsoft\Windows\CurrentVersion\Run"
Dim regkey As Microsoft.Win32.RegistryKey
regkey = My.Computer.Registry.CurrentUser.OpenSubKey(regpath, True)
regkey.SetValue("CalculatorAtStartup", "c:\windows\system32\calc.exe")
regkey.Close()