How to start app at startup ?

K

Kunal

Hi friends,

I'm faced with a requirement that is kind of unknown to me.

In my situation, if my application was running and the machine
reboots, then I need to start my
application automatically once the machine comes up. If the
application was closed by the user
then it should not come up at system reboot next time.

One way to do this could be to write a small program which reads a
"status" from a file which
will be written to by the application while it is running. The app
would write "Running" when it is executing or "Not Running" when it is
closed, to this file. I could then install this program as a windows
service to start up automatically at reboot time. There it would check
up the
contents of the status file and take appropriate action.

I've heard this can also be achieved through some registry work.

Are there any other ways of doing this ? What would be the best,
easiest and efficent way
of doing this ?

Thanks n Regards,
Kunal
 
M

Michael Nemtsev

Hello kunal,

k> I'm faced with a requirement that is kind of unknown to me.
k>
k> In my situation, if my application was running and the machine
k> reboots, then I need to start my
k> application automatically once the machine comes up. If the
k> application was closed by the user
k> then it should not come up at system reboot next time.

When your app starts put the record at HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

which run your app after next logon.
If user gracefully close you app just remove that record.

Other way to load app automatically is create shortcut to you app in Startup
folder

---
WBR, Michael Nemtsev [C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top