|
-
Jun 7th, 2006, 08:21 AM
#1
Thread Starter
Hyperactive Member
[1.0/1.1] Starting up a program automatically when the computer re-boots
Hi. I'm creating a window application and not a service. If it was a service it would start automatically when the computer re-boots. However how do you program your window application to start automatically when the program re-boots?
I know of one way and that is to insert the .exe file in the STARTUP menu in the program list but this is too obvious and the user could delete it by mistake. Is there any other way to enable a window application to start automatically when the computer re-boots?
Jennifer.
I was just researching, is there a way to set a registry key to have your program start up automatically?
Last edited by drattansingh; Jun 7th, 2006 at 08:50 AM.
-
Jun 7th, 2006, 11:53 AM
#2
Not NoteMe
Re: [1.0/1.1] Starting up a program automatically when the computer re-boots
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Anything in there should run upon windows startup. The type of value to create in there is a string (shows up as REG_SZ in the values list).
The data is what you want to run (with command line params there too, if your program requires them).
If you want your program to only run once (first time windows is restarted) the put your value in the RunOnce key (or possibly RunOnceEx, not sure which would be best.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Jun 7th, 2006, 02:02 PM
#3
Thread Starter
Hyperactive Member
Re: [1.0/1.1] Starting up a program automatically when the computer re-boots
oK. I checked and found the registry key. Now I do not want to put it there manually. Is there anyway in c# I could set the directory? Either from the setup build or probably everytime the program starts, check to see if its set, and if not, then set it. Is that possible with some pseudocode or some reference?
-
Jun 12th, 2006, 08:11 AM
#4
Thread Starter
Hyperactive Member
Re: [1.0/1.1] Starting up a program automatically when the computer re-boots
Nobody knows? Does this mean that I cannot do this through a C sharp program?
Jennifer
-
Jun 12th, 2006, 08:57 AM
#5
Re: [1.0/1.1] Starting up a program automatically when the computer re-boots
You can create the registry entry with your setup project and you can put code in your app to check for that registry value each time it shuts down, but there is no way for your app to check the registry after it is closed, so if the user deletes the key after your app is shut down then your app will not start with Windows. Getting and setting information from the registry is just a matter of using the Microsoft.Win32.Registry and .RegistryKey classes.
Last edited by jmcilhinney; Jun 12th, 2006 at 07:21 PM.
-
Jun 12th, 2006, 01:18 PM
#6
Re: [1.0/1.1] Starting up a program automatically when the computer re-boots
I hope this helps
Code:
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run",true).SetValue("MyApp",Application.ExecutablePath);
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jun 12th, 2006, 01:41 PM
#7
Thread Starter
Hyperactive Member
Re: [1.0/1.1] Starting up a program automatically when the computer re-boots
Thanks guys, i'll try it out and post back a reply - Jen
-
Jul 25th, 2006, 08:54 AM
#8
Thread Starter
Hyperactive Member
Re: [1.0/1.1] Starting up a program automatically when the computer re-boots
Hi. I tried it out and it worked. However there is a little problem. I developed a very simple application with a notify icon, when the computer booted, the application started, but not the notify icon. I checked in the processes and the program was started. I tried it again with some applications, and when the computer booted, the program started but the forms didnt display. It seems to me that apparently it is starting before some critical feature necessary to bring up the forms. Anyone knows how to solve this problem?
Jennifer
-
Jul 26th, 2006, 10:40 AM
#9
Thread Starter
Hyperactive Member
Re: [1.0/1.1] Starting up a program automatically when the computer re-boots
Ok. I found the error but dont know how to solve it. When I have this program, and starts it, it starts fine, but when it starts after a reboot it fails. In my program I am reading a file: file.xml which is located:
@"Files\file.xml"
Now when the program starts from the auto-reboot, what is happenning is that it is not reading the path of the folder where the files exist. So that the path statement is actually:
c:\Documents and settings\Administrator\Files\file.xml
to which it is generating the file does not exist. Now the real path to the application folder is:
c:\Program Files\home\test\bin\debug
in that path, i have a folder called Files and only one file: file.xml.
Apparently it is reading the default path as the desktop.
Originall I had:
Microsoft.Win32.Registry.LocalMachine....
I changed it to:
Microsoft.Win32.Registry.CurrentUser....
but it is not working, the same problem. Wierd problem, why when I say:
@\Files....
It is assuming c:\....\Desktop\Files\file.xml
-
Jul 26th, 2006, 12:02 PM
#10
Re: [1.0/1.1] Starting up a program automatically when the computer re-boots
Use
Code:
Application.StartupPath+@"\Files\file.xml";
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jul 27th, 2006, 09:02 AM
#11
Thread Starter
Hyperactive Member
Re: [1.0/1.1] Starting up a program automatically when the computer re-boots
LOL. that simple huh, Thanks!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|