VB.NET for beginners : How to create Startup Event Program and add My Application to Windows Startup?
VB.NET Tutorials : Make your program Run at windows startup, today i will show you how to create simple application using vb.net that make our application Run automatically at windows is startup. The application will automatically by writing a value entry (a complete name/value pair) to any of the following registry keys.
Please read :
See you next lessons
Please read :
Make your application run at Startup
Just create a new project or one of your existing project and write all source code belowRun at Windows Startup with writing a value entry to Registry Keys :
'the code will Write to the register
Dim registryKey As Microsoft.Win32.RegistryKeyregKey
registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
registryKey.SetValue("AppName", "InstallationPath")
registryKey.Close()
To delete from Registry just write this code :
'the code will Write to the register
Dim registryKey As Microsoft.Win32.RegistryKeyregKey
registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
registryKey.DeleteValue("AppName", False)
registryKey.Close()
Add your Application to Startup with Copying files to Startup Folder :
Dim Myfile As New FileInfo(application.startuppath)
' codpy it to the startup folder
Myfile.CopyTo(My.Computer.FileSystem.SpecialDirectories.Programs + "\startup\myapp.exe")
See you next lessons
COMMENTS