1

I am creating wpf application using visual studio 2010 specifically for windows 7 operating system. Now I want my wpf app to start when ever computer starts. I googled it and wrote service but couldn't succeeded what I need. I do not know how to use that service properly or how to make one installer of both service project and wpf project ( I am new to wpf dev).

this is the code I found on msdn forum but do not know if I am using it right way - I think I am not giving right path of exe file

 protected override void OnStart(string[] args)
    {
        ProcessStartInfo info = new ProcessStartInfo(@"C:\Users\Zeshan\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\TaskManagerPro");
        info.CreateNoWindow = false;
        Process p = new Process();
        p.StartInfo = info;
        p.Start();
    }

Please guide me to the right direction and if possible kindly share some source code and also guide what is the best way to create installer.

rene
  • 41,474
  • 78
  • 114
  • 152
Zeshan Aman
  • 103
  • 3
  • 13
  • 3
    An easy way to do this is to just put a shortcut to your exe in the startup folder. – DROP TABLE users Jan 08 '14 at 17:22
  • How I can do it programmatically? – Zeshan Aman Jan 08 '14 at 17:24
  • 1
    see this http://stackoverflow.com/questions/1036093/how-do-i-create-add-a-shortcut-lnk-for-my-application-to-the-startup-folder-p – yo chauhan Jan 08 '14 at 17:30
  • ethicallogic the code in the answer will automatically create the shortcut when I run the installer? or how to use it ? – Zeshan Aman Jan 08 '14 at 17:47
  • I tried the code given under answers http://stackoverflow.com/questions/1036093/how-do-i-create-add-a-shortcut-lnk-for-my-application-to-the-startup-folder-p but it not letting me do this , throwing authorization exception. – Zeshan Aman Jan 08 '14 at 19:12
  • Possible duplicate of [How to run a C# application at Windows startup?](https://stackoverflow.com/questions/5089601/how-to-run-a-c-sharp-application-at-windows-startup) – Hakan Fıstık Apr 21 '18 at 09:43

2 Answers2

0

Try this solution from this answer: https://stackoverflow.com/a/5527457/2696641

Modifying a current user registry items do not require admin access.

Community
  • 1
  • 1
0

Add you value to HKCU\Software\Microsoft\Windows\CurrentVersion\Run.

John Smith
  • 496
  • 1
  • 6
  • 20