Start on start-up
hey what is the code for if i have a checkbox on my app and when that checkbox is checked = the program will start on start up next re boot? then once unchecked it will not start on start up?
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim FileName As String
Dim FilePath As Object
Dim RegistryKey As Object
FileName = "StartupTutorial.exe"
FilePath = Path.GetFullPath(FileName)
RegistryKey = CreateObject("WScript.Shell") RegistryKey.RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\StartupTutorial", FilePath) End Sub
End Class
Dim RegistryK As RegistryKey
RegistryK = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
RegistryK.SetValue("Your FIle Name.exe", "Your FIle Location\Your FIle Name.exe")
RegistryK.Close()
My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).SetValue(Application.ProductName, Application.ExecutablePath)