Hi there. I have a question. I want to make an Option in my application so the user can decide if it should be put into the startup folder. so, how can i write into the registry, or create a shortcut into the startup folder - and how can i delete it, if the user uncheck the option
I already opened a thread like this, but i forgot that the english name for the startup folder is different from the german one ( autostart ) which may cause irritations..

making the program starting with windows via registry
Lauski
thank you very much (: i try this now :)
edit: VB says that the type "registry key" is not decfined.. how to define it
(sorry if my questions are stupid but i didnt code for some months and i never tried .net before)
Zaka Khan
ya! That worked, when I changed RegistryKey to Microsoft.Win32.RegistryKey! Thank you very much!
-Eric Bouguen-
To create a Registry key, use <system directory>/regedit.exe.
HKey_LocalMachine\Software\Microsoft\Windows\CurrentVersion\Run
A new key has a name Such as "RenClock"
and will specify the path of your program:
"C:\Program Files\RenClock\RenClock.exe"
Please note however, that just because the program starts in this manner does NOT guaratee that the program will be able to interact with a user's desktop. If that is what you need, you will need to create a startup icon.
I've done similar, not with One-Click, but with an installation project as part of a solution.
However.... such a project is not supported under Visual Basic Express.
asics64
is this possible anyway - to create (and delete) a startup icon during runtime
Oh, okay.. than it is already solved..
but - thank you anyway
Dragan Jankovic
If your place a registry key in HKey_LocalMachine\Software\Microsoft\Windows\CurrentVersion\Run the program will start with windows.
Public Function AppPath() As String
Return System.IO.Path.GetDirectoryName(Reflection.Assembly.GetEntryAssembly().Location)
End Function
Private Sub chkAutoStart_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkAutoStart.CheckedChanged
Dim rk As RegistryKey = Registry.LocalMachine
Dim myKey As RegistryKey
myKey = rk.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
If chkAutoStart.Checked Then
myKey.SetValue("OnteoraKey", AppPath() & "\PrintScreen.exe")
Else
myKey.DeleteValue("OnteoraKey")
End If
End Sub