Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to register my app in registry in order to run it with windows startup, it works fine in my PC but doesn't work in another PCs, this is my code :
RegistryKey RK = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", true);
RK.SetValue("Savabegh", Application.ExecutablePath.ToString());

Please help.
Updated 11-May-11 1:24am
Sandeep Mewara 11-May-11 4:44am    
What do you mean by it does not work? You get any error? what?

You need to have appropriate permissions (on the client) to write into the registry.
Share this answer
Sergey Alexandrovich Kryukov 11-May-11 4:55am    
It could be a problem as well, my 5.
Abhinav S 11-May-11 7:55am    
Thanks for the 5.
mehdi_k 11-May-11 7:26am    
I think this is because of permission but how can I get the permission?
Sergey Alexandrovich Kryukov 11-May-11 10:26am    
You never tell us what's the OS in first and second case, you did not confirm if you need the start for all user or one, on what event. If this is Windows 7, you need to run your application with elevated privileges, even if you're the administrator.
mehdi_k 13-May-11 4:15am    
Yes I'v Win7 on my PC and I want to start for one user, but my app has problem even in win xp!! and I still don't know what to do!
Please help me about this.
This could would not even compile. Please make sure it compiles and paste the code right from your real code sample. The key should be in quotation marks.

Even though this is not cause any error Application.ExecutablePath.ToString(), this is ridiculous: ToString is redundant because ExecutablePath is already a string.

Now, I'm not sure CurrentUser is right. More likely, the key should be:

Perhaps you tried to register software for one user and tried to run it as another one.

What else? Here is my secret weapon to find out all points where an application can be started: Sysinternals AutoRuns. Load Sysinternals Suite:[^], unpack and run AutoRuns, read its help, find all places where the program can be started automatically. There is a feature to jump to the registry key from any item using Regedit. This utility will provide you comprehensive information on the topic.

Share this answer
Abhinav S 11-May-11 7:55am    
Good answer. My 5.
Sergey Alexandrovich Kryukov 11-May-11 10:23am    
Thank you, Abhinav.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900