Que tal tio, con el app.path te crea la clave donde se encuentre tu .exe, no se como guardar el valor de un check1.value por eso utilizo un text1 para guardar el valor del check en el registro, en este caso necesitas un text1 y check1, ya lo probre y funciona bien, esta un poco chamullado el codigo pero puedes reducir el numero de funciones a tu antojo o colocarla en un modulo
Código:
Public Sub Crear_clave()
'crear clave de registro
Dim sh As Object
Set sh = CreateObject("WScript.Shell")
sh.RegWrite ("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\programa01"), App.Path & "\programa01.exe", "REG_SZ"
Set sh = Nothing
End Sub
Public Sub Eliminar_clave()
'eliminar del registro
Dim sh As Object
Set sh = CreateObject("WScript.Shell")
sh.RegDelete ("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\programa01")
Set sh = Nothing
End Sub
Function LeerRegistro(ElControl As Control) As String
'Text1 = LeerRegistro(Text1)
LeerRegistro = GetSetting(App.EXEName, "Settings", ElControl.Parent.Name & "_" & ElControl.Name)
End Function
Function GuardarRegistro(ElControl As Control)
'GuardarRegistro Text1
SaveSetting App.EXEName, "Settings", ElControl.Parent.Name & "_" & ElControl.Name, ElControl
End Function
Private Sub Check1_Click()
'Si el check esta activo entonces crea la clave y llenamos el text con 1 para guardar dicho valor
If Check1.Value = 1 Then
Crear_clave
Text1.Text = "1"
Else
Eliminar_clave
Text1.Text = "0"
End If
End Sub
Private Sub Form_Load()
Text1 = LeerRegistro(Text1)
If Text1 = "1" Then
Check1.Value = 1
Else
Check1.Value = 0
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
GuardarRegistro Text1
End Sub