Windows Develop Bookmark and Share   
 index > Windows Forms General > Open EXE ie.Application as soon as Computer Starts
 

Open EXE ie.Application as soon as Computer Starts

Hi All,

I am Using VS03 + Winforms .I have created application and also setup successfully.

Now i want as soon as when users computer starts at that time my login page will be shown(ie.open ) to user instead the user click on exe which is present on dekstop.

It is just like GOOGLE TALK EXE,Which is directly open as soon as Computer starts.

So anyone help me about this.What settings i have to do? or wheather it is done programatically.

Thanks in advance.

sunDAC  Friday, May 16, 2008 12:15 PM

Hi san7481,

As Giorgi Dalakishvili said, you can put your programs shortcut in startup folder (in All Programs of Start menu). You need to add the shortcut to the User’s Startup Folder. Here is some guidance for you reference.

· http://support.microsoft.com/kb/307358

· http://msdn.microsoft.com/en-us/library/s2esdf4x.aspx

· http://msdn.microsoft.com/en-us/library/k3bb4tfd(VS.80).aspx

Another choice is to use the Custom Action to add a registry item to auto run you application. You also need a Custom Action to remove this registry item when uninstalling the application.

Code Snippet

[RunInstaller(true)]

public partial class Installer1 : Installer

{

public Installer1()

{

InitializeComponent();

}

protected override void OnAfterInstall(System.Collections.IDictionary savedState)

{

base.OnAfterInstall(savedState);

string appDirPath = Context.Parameters["PathDir"];

RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);

key.SetValue("MyApp", "\"" + appDirPath + "MyApp.exe\"");

key.Close();

}

protected override void OnAfterUninstall(System.Collections.IDictionary savedState)

{

base.OnAfterUninstall(savedState);

RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);

key.DeleteValue("MyApp");

key.Close();

}

}

For more information about custom action, please check:
http://msdn.microsoft.com/en-us/library/aa368066(VS.85).aspx
http://msdn.microsoft.com/en-us/library/d9k65z2d(VS.80).aspx
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3029732&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3056936&SiteID=1

Hope this helps.
Best regards.
Rong-Chun Zhang

Windows Forms General FAQs
Windows Forms Data Controls and Databinding FAQs

Rong-Chun Zhang  Wednesday, May 21, 2008 10:00 AM
You need to add your application to windows start-up. Here is an example showing how to do it programmatically:
Managing Start-up
Giorgi Dalakishvili  Friday, May 16, 2008 12:46 PM

hi,

thanks for the reply.I have going through the link which you provided.It is given me good details.

I just want to ask you is there any alternative solution such that can i do something during setup creation insted of tedious coding.I have read while searching that during setup creation we can do somthing.

Do you have any idea about this?

Waiting for the reply.

sunDAC  Monday, May 19, 2008 6:40 AM
One possible way is putting your programs shortcut in startup folder. That will help.
Giorgi Dalakishvili  Monday, May 19, 2008 7:19 AM

hi,

Thanks for reply.I really cant get your point.Can you please elabrate tour point.

So i will get idea.

Waiting for the reply.

sunDAC  Monday, May 19, 2008 10:40 AM

Hi san7481,

As Giorgi Dalakishvili said, you can put your programs shortcut in startup folder (in All Programs of Start menu). You need to add the shortcut to the User’s Startup Folder. Here is some guidance for you reference.

· http://support.microsoft.com/kb/307358

· http://msdn.microsoft.com/en-us/library/s2esdf4x.aspx

· http://msdn.microsoft.com/en-us/library/k3bb4tfd(VS.80).aspx

Another choice is to use the Custom Action to add a registry item to auto run you application. You also need a Custom Action to remove this registry item when uninstalling the application.

Code Snippet

[RunInstaller(true)]

public partial class Installer1 : Installer

{

public Installer1()

{

InitializeComponent();

}

protected override void OnAfterInstall(System.Collections.IDictionary savedState)

{

base.OnAfterInstall(savedState);

string appDirPath = Context.Parameters["PathDir"];

RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);

key.SetValue("MyApp", "\"" + appDirPath + "MyApp.exe\"");

key.Close();

}

protected override void OnAfterUninstall(System.Collections.IDictionary savedState)

{

base.OnAfterUninstall(savedState);

RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);

key.DeleteValue("MyApp");

key.Close();

}

}

For more information about custom action, please check:
http://msdn.microsoft.com/en-us/library/aa368066(VS.85).aspx
http://msdn.microsoft.com/en-us/library/d9k65z2d(VS.80).aspx
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3029732&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3056936&SiteID=1

Hope this helps.
Best regards.
Rong-Chun Zhang

Windows Forms General FAQs
Windows Forms Data Controls and Databinding FAQs

Rong-Chun Zhang  Wednesday, May 21, 2008 10:00 AM

Hi Rong-Chun Zhang,

Thanks for the reply. I have gone through all the links which toy provided me.

It gives me detailed information about setup which i really dont know.

Thank You Very Much.

Cheers!

san7481

sunDAC  Thursday, May 22, 2008 10:42 AM

hi,

I have created shortcut in the User's Startup Folder. So that whenever i start my copmuter then my application get started.It runs fine.

I want use user interface so that user can decide wheather user want shortcut on startup menu or not.

means i want to give user facility such that user decides wheather he wants to pop up the application next time when computer get started or not.

Hope you understand my problem.

Waiting for the reply.

sunDAC  Thursday, May 22, 2008 11:29 AM
Why don't you have a look at the link I gave you? It has a checkbox that allows to add or remove application from startup. Here is the link: Managing Start-up
Giorgi Dalakishvili  Thursday, May 22, 2008 4:11 PM

You can use google to search for other answers

Custom Search

More Threads

• The new .NET 2.0 ConfigurationManager and Associated Classes
• serialization
• Adding treeView Node dynamiclly..
• Text box text format checking
• GDI+ Book
• How to catch WebBrowser error before dispose?
• DataGridViewRow.Tag
• Problem with setting UseVisualStyleBackColor (and other new properties)
• facing problem object referrance not set to an instance of object?
• Scrollable ToolStrip control?