How can I get my application to start with windows? I know I can add a link to the "startup" folder and it will sometimes start when windows starts, but that doesn't work all the time.
is there a code or an option or something I can use?
Start program when windows startsvb.net
Page 1 of 1
10 Replies - 18673 Views - Last Post: 29 October 2008 - 05:57 PM
Replies To: Start program when windows starts
#2
Re: Start program when windows starts
Posted 20 November 2006 - 12:04 PM
You could also add an entry into the Run key in the registry. This and adding to the startup folder are the only two ways I know of having an application execute on startup of Windows.
You will need to add it as a new String.
The key is located here:
You will need to add it as a new String.
The key is located here:
My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
#3
Re: Start program when windows starts
Posted 20 November 2006 - 12:22 PM
ok, how do i access the registry in code though?
I got My.Computer.Registry.LocalMachine... and that's where I peter out
I got My.Computer.Registry.LocalMachine... and that's where I peter out
#4
Re: Start program when windows starts
Posted 20 November 2006 - 01:45 PM
First thing you need to do is import Imports Microsoft.Win32. Also make sure you have administrative privileges on the computer, otherwise none of this will work.
Then to give you an example of how to code it:
First step is to create a RegistryKey data type to contain the key of where you want to write the information. Make sure the boolean is set to True, this means you want to read/write to the SubKey. If it is false then it will be read only.
The next step is to set the value of the new entry using the SetValue method. The first parameter is the name it will be called inside the registry, can be pretty much anything you want to call it.
The second parameter is the physical path to where you have your executable stored.
Last but not least, DON'T forget to close the SubKey when you are done.
This example will create a value name in the Run SubKey called MyExecutable and the value data of C:\MyExecutable.exe.
Then to give you an example of how to code it:
Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
regKey.SetValue("MyExecutable", "C:\MyExecutable.exe")
regKey.Close()
First step is to create a RegistryKey data type to contain the key of where you want to write the information. Make sure the boolean is set to True, this means you want to read/write to the SubKey. If it is false then it will be read only.
The next step is to set the value of the new entry using the SetValue method. The first parameter is the name it will be called inside the registry, can be pretty much anything you want to call it.
The second parameter is the physical path to where you have your executable stored.
Last but not least, DON'T forget to close the SubKey when you are done.
This example will create a value name in the Run SubKey called MyExecutable and the value data of C:\MyExecutable.exe.
#5
Re: Start program when windows starts
Posted 20 November 2006 - 01:56 PM
I actually figured it out before this. But it's good because now other people can read this.
Question though. What happens if I forget to close the subkey?
Question though. What happens if I forget to close the subkey?
#6
Re: Start program when windows starts
Posted 20 November 2006 - 02:24 PM
Per the MSDN
My understanding is that it basically writes the registry changes to disk, otherwise the changes only exist in the registry that is currently loaded into memory and as such are lost upon reboot.
RegistryKey.Close method MSDN.
Quote
Closes the key and flushes it to disk if its contents have been modified.
My understanding is that it basically writes the registry changes to disk, otherwise the changes only exist in the registry that is currently loaded into memory and as such are lost upon reboot.
RegistryKey.Close method MSDN.
#7
Re: Start program when windows starts
Posted 20 November 2006 - 02:30 PM
You are wise
#8
Re: Start program when windows starts
Posted 28 October 2008 - 02:09 AM
Hi, i did exactly the same thing in Windows Vista and the ex.message noted that i do not have the permission to do this....
Any chance you know a solution to this problem?:s
Any chance you know a solution to this problem?:s
#9
Re: Start program when windows starts
Posted 28 October 2008 - 03:14 AM
i don't know the benefits of one over the other but i found the easiest thing to do is to place a shortcut in the startup folder.
#11
Re: Start program when windows starts
Posted 29 October 2008 - 05:57 PM
What about creating a shortcut in the startup directory?
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote






|