tags:

views:

79

answers:

2

Hi, 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 automatically started after setup finishes?

Thanks Furqan

+1  A: 

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

Louis Rhys
@Louis Rhys I don't think this is a good idea.
Searock
@searock: why not?
Louis Rhys
Most of the startup applications create a key in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Searock
A: 

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.

Searock
I am sorry, I am still unable to do it. Actually user chooses where the application is installed. Could you give me complete code how to manage it?ThanksFurqan
I will post a sample code once I reach home.
Searock
Could you kindly give me an idea how I can make Setup to add this registry key so my application runs at startup of windows? Thanks