Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Windows
I want to start my application on start up of windows.
For that i have used
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run registry value
and it worked correct.
 
But now i want to set the registry value from c# code
but i cann't edit or add new value in registry programtically.
can u say how to do this???
Posted 1-Jan-13 2:11am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

If you are trying to write to HKLM, make sure that you have admin privileges. If not the registry write attempt will fail. I suspect that you are manually adding the value from one (admin) username and trying to run your program from another (non-admin) username.
  Permalink  
Comments
Hetal Jariwala at 2-Jan-13 23:10pm
   
I have done it manually and it worked perfectly.
But when i'm trying to do this from c# it is not changing at all.
H.Brydon at 3-Jan-13 0:00am
   
Reading or writing anything in the registry from code requires multiple steps. Each of these steps gives you a return code. Make sure you look at every return code and make sure you have success at each step.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

You can add a shortcut of the program to the startup folder in the start menu, that should start your program everytime you start the OS.
  Permalink  
Comments
Hetal Jariwala at 2-Jan-13 23:09pm
   
But by that way operator can easily remove program from startup
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You need to use the resgitry class to access (read or write) registry values.
 
http://msdn.microsoft.com/en-us/library/5f1xf5kf.aspx[^]
 
Look at this article to get a heads up:
 
http://www.switchonthecode.com/tutorials/csharp-snippet-tutorial-editing-the-windows-registry[^]
  Permalink  
Comments
Hetal Jariwala at 2-Jan-13 3:20am
   
I have written this way but i cann't access the LOCAL_MACHINE assembly....
Hetal Jariwala at 2-Jan-13 3:20am
   
How to solve this??
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
 
Here you read how to read, write and delete from registry:
Read, write and delete from registry with C#[^]
Another way to start an application automatically, is to create a shortcut to your application in the Startup folder:
Run C# application on user logon (Windows Forms)[^]
  Permalink  
Comments
Hetal Jariwala at 2-Jan-13 3:20am
   
I have written this way but i cann't access the LOCAL_MACHINE assembly....
Hetal Jariwala at 2-Jan-13 3:20am
   
How to solve this??

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



Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100