How to start a program/process at system startup in c#?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dotnetnovice
    New Member
    • Aug 2009
    • 21

    #1

    How to start a program/process at system startup in c#?

    Hi...
    I want some help in registry editing Actually i am using this code

    Code:
    namespace ConsoleApplication2
    {
        class Win_start
        {
            static void Main(string[] args)
            {
                RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                
                rk.SetValue("a", Process.Start("c:/test.pdf"));
            }
        }
    }
    It works well when i run the application from visual studio but it does not works when system starts. however it set registry well.

    Thanks
  • Aimee Bailey
    Recognized Expert New Member
    • Apr 2010
    • 197

    #2
    perhaps its not understanding how to open a pdf on start. You could use the fully qualified name instead...

    Code:
                rk.SetValue("a", Process.Start(string.Format("\"{0}\" \"{1}\"",
                                               @"C:\Program Files (x86)\Adobe\Reader 9.0\Reader\AcroRd32.exe",
                                               @"c:\test.pdf")));
    Note im running 64bit, so my Program Files folder with adobe reader in has an (x86) after the name.

    Comment

    Working...