CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2005
    Posts
    23

    Question Making my application a startup program?

    I have just finished writing a program in Visual Basic.NET and would like for it to automatically make itself a startup program (one of the processes that starts automatically when Windows starts) during run time. Is there a way to program this right into the code itself, without having to make an installation file? For example, if I had a button on my form that said "Make me a starup program!", the user can click it and it would execute the necessary code to do this. What exactly would be the code for this button? Any help would be greatly appreciated!

    Thanks,
    Chopinzee

  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: Making my application a startup program?

    Just put the EXE or a shortcut to it in the Startup folder.

  3. #3
    Join Date
    Feb 2005
    Posts
    23

    Re: Making my application a startup program?

    Yes but I don't want the end user to have to copy the program to the startup folder themselves, I want the program to do it automatically during run time.

  4. #4
    Join Date
    Jan 2005
    Posts
    8

    Re: Making my application a startup program?

    hi why dont you put the code in a window service and make it start automatically as OS starts. i think its a better option. sorry i had the same idea to copy the exe in Startup folder. anyways

  5. #5
    Join Date
    Nov 2004
    Location
    North Idaho
    Posts
    18

    Re: Making my application a startup program?

    Alternately you can manually create a new string value registry key in:
    HKLM\Software\Microsoft\Windows\CurrentVersion\Run\
    I would caution that improperly adding an application as a startup item can have harsh and unexpected results. Edit the Windows registry at your own risk.

    DS

  6. #6
    Join Date
    Feb 2005
    Posts
    23

    Question Re: Making my application a startup program?

    Quote Originally Posted by 4461766964
    Alternately you can manually create a new string value registry key in:
    HKLM\Software\Microsoft\Windows\CurrentVersion\Run\
    I would caution that improperly adding an application as a startup item can have harsh and unexpected results. Edit the Windows registry at your own risk.

    DS
    So how do you do this? Like what would the code be for example?

  7. #7
    Join Date
    Feb 2005
    Posts
    23

    Unhappy Re: Making my application a startup program?

    Surely someone must know...

  8. #8
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080

    Re: Making my application a startup program?

    I don't have much time to show you but check that namespace in .NEt

    microsoft.Win32

    should help you out with the registry.
    Nicolas Bohemier

  9. #9
    Join Date
    Feb 2005
    Posts
    10

    Re: Making my application a startup program?

    I know in C# the code is as folows

    include this using statement using Microsoft.Win32;

    create a registry key object

    RegistryKey rootkey,pKey,sKey;


    then the fun begins the following line is how to open a connection
    rootkey = Registry.LocalMachine.OpenSubKey("Software", true) this can be any key

    once the initial connection is made you have to make the keys in the registry to store you're data

    pKey = rootkey.CreateSubKey("KeyName"); this creates a key under Software
    sKey = pKey.CreateSubKey("KeyName"); this creates a key under the one created with pKey;

    now to set values use the sKey object to create them

    sKey.CreateKey("Key Name", (string)Keyvalue);
    sKey.CreateKey("Key Name", (int)Keyvalue);
    and so on then use

    sKey.Close();
    pKey.Close();
    rootkey.Close();

    this is what i have done if any further help is needed email me at jscheibe@cogeco.ca

    Josh

  10. #10
    Join Date
    Feb 2005
    Posts
    6

    Re: Making my application a startup program?

    If you don't want to copy the exe to the startup folder, you could create a shortcut to the exe in the startup folder.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured