Using some code that LPlates provided (and it works great by the way!) I am trying to figure out how to remove a registry entry during a reboot with a boot disk.
LPlates code sets the app so that if it is terminated by windows, for example pressing reset on the box , then the app restarts with windows. However the problem I am trying to solve is that the app requires a password to shut it down, let's say the user forgets their password, I want to be able to give them a 3.5 inch floppy, tell them to insert it and then reboot, when the system reboots, the "boot disk" resets the registry entry so that the app won't auto start, in other words remove the registry startup entry. Is this possible? Here is the code that creates the entry:
Const REG_SZ = 1
Const HKEY_CURRENT_USER = &H80000001
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim hKey As Long
Dim strRunCmd As String
If UnloadMode = vbAppWindows Then
strRunCmd = App.Path & "\" & App.EXEName & ".EXE"
Call RegCreateKey(HKEY_CURRENT_USER, _
"Software\Microsoft\Windows\CurrentVersion\RunOnce", hKey)
Call RegSetValueEx(hKey, "CCL.exe", 0&, REG_SZ, ByVal strRunCmd, _
Len(strRunCmd) + 1)
Call RegCloseKey(hKey)
End If
LPlates code sets the app so that if it is terminated by windows, for example pressing reset on the box , then the app restarts with windows. However the problem I am trying to solve is that the app requires a password to shut it down, let's say the user forgets their password, I want to be able to give them a 3.5 inch floppy, tell them to insert it and then reboot, when the system reboots, the "boot disk" resets the registry entry so that the app won't auto start, in other words remove the registry startup entry. Is this possible? Here is the code that creates the entry:
Const REG_SZ = 1
Const HKEY_CURRENT_USER = &H80000001
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim hKey As Long
Dim strRunCmd As String
If UnloadMode = vbAppWindows Then
strRunCmd = App.Path & "\" & App.EXEName & ".EXE"
Call RegCreateKey(HKEY_CURRENT_USER, _
"Software\Microsoft\Windows\CurrentVersion\RunOnce", hKey)
Call RegSetValueEx(hKey, "CCL.exe", 0&, REG_SZ, ByVal strRunCmd, _
Len(strRunCmd) + 1)
Call RegCloseKey(hKey)
End If