Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

vb.net - How to make my program run at startup?

I'm programming a desktop application similar to Google desktop but with my own gadget with vb.net 2008 how can i make my application when the user install it on their computer to run at the time of start up?

Let assume that my application name is windowsAplication1 and I'm using windows XP and the program will be installed on C drive?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can add it to registry with the following code

My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWAREMicrosoftWindowsCurrentVersionRun", True).SetValue(Application.ProductName, Application.ExecutablePath)

you can remove it using

My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWAREMicrosoftWindowsCurrentVersionRun", True).DeleteValue(Application.ProductName)

The above code will add it to all users. You can add it to current user in the following key

HKEY_CURRENT_USERSOFTWAREMicrosoftWindowsCurrentVersionRun

Or you can add a link to your application in the "Startup" folder.

I suggest you dont do it automatically it may irritate the user. I hate when apps add them automatically to Windows Startup. Give an option for the user to run the program on windows startup.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...