How can I add my application in startup items? I want my application to get added in startup when setup is run at Client's computer.
Also, how can it be a开发者_JAVA百科utomatically started after setup finishes?
Thanks Furqan
Create a new string value in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run in registry.
For example if you application name is Test and resides in c:\programfiles\test\test.exe then
create a string value called Test and save the path c:\programfiles\test\test.exe in the string value.
Let me know if you want the setup to add your application as startup application.
Edit 1:
Sample code :
Imports Microsoft.Win32
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim regStartUp As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
Dim value As String
value = regStartUp.GetValue("Myapp")
If value <> Application.ExecutablePath.ToString() Then
regStartUp.CreateSubKey("Myapp")
regStartUp.SetValue("Myapp", Application.ExecutablePath.ToString())
End If
End Sub
End Class
You can find more details about registry here and details about registry class here.
Let me know if you have any problem with the code.
Create a shortcut or a batch file that runs your program in in Start menu > Programs > Startup folder
for example in win XP this folder would be C:\Documents and Settings\All Users\Start Menu\Programs\Startup or C:\Documents and Settings[YOURUSERNAME]\Start Menu\Programs\Startup
精彩评论