I can enable or disable task manager manually. like: start> run > gpedit.msc
from group policy setting > user configuration > administrative templetes> system>
ctrl+alt+del. I want to do it in vb6. If click a button then it disable or enable. Is it
possible to do? If yes then how?

Dani AI

Generated

Short answer: yes. Rather than trying to intercept secure key combos, toggle the same Windows policy the OP mentioned by changing the registry value that controls Task Manager for the current user. In VB6 the easiest, least‑intrusive way is to use WScript.Shell's RegWrite to set or clear the policy value.

Dim sh As Object
Set sh = CreateObject("WScript.Shell")

' Disable Task Manager (current user)
sh.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr", 1, "REG_DWORD"

' Re-enable: set to 0 or delete the value
sh.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr", 0, "REG_DWORD"
' or: sh.RegDelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr"

Set sh = Nothing

Notes and troubleshooting: writing under HKCU does not require elevation; writing under HKLM (machine‑wide) does and may be affected by UAC and WOW64 redirection (HKCU is not redirected). Domain Group Policy will override local changes. Changes usually take effect for new processes immediately; if Task Manager stays available, close and re-open it or sign out/in. Make sure the value is a REG_DWORD and the full key path exists (RegWrite will create missing keys).

Context for the thread: this avoids brittle approaches discussed earlier — pointed out SendKeys is unreliable and demonstrated keyboard‑intercept tactics that are easy to bypass on modern Windows. The registry/policy method is more reliable, but not foolproof: administrators, domain GPOs, or security software can override or revert it.

Cautions: only change system/user policies with informed consent (kiosk/admin scenarios). Test on a non‑admin account first and provide a clear restore path (set to 0 or delete the value).

Recommended Answers

All 8 Replies

Just remember that Sendkeys will NOT work in Vista or Win7.

I took the entire long route which works wonders. If someone knows what they are doing, they can still use task manager....

This will disable it until the application is closed.

Public Declare Function SystemParametersInfo Lib "user32.dll" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long



x = SystemParametersInfo(97, 1, CStr(1), 0) 'Disable Ctrl+Alt+Del Keys combination
'Use as in --->>>
If KeyAscii >= vbKeyA And KeyAscii <= vbKeyZ Or KeyAscii >= 97 And KeyAscii <= 122 Or KeyAscii >= vbKey0 And KeyAscii <= vbKey9 Or KeyAscii = vbKeyBack Then
        'do nothing
    Else
        KeyAscii = 0    'Disable all other key strokes
    End If

Just remember that Sendkeys will NOT work in Vista or Win7.

I took the entire long route which works wonders. If someone knows what they are doing, they can still use task manager....

This will disable it until the application is closed.

Public Declare Function SystemParametersInfo Lib "user32.dll" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long



x = SystemParametersInfo(97, 1, CStr(1), 0) 'Disable Ctrl+Alt+Del Keys combination
'Use as in --->>>
If KeyAscii >= vbKeyA And KeyAscii <= vbKeyZ Or KeyAscii >= 97 And KeyAscii <= 122 Or KeyAscii >= vbKey0 And KeyAscii <= vbKey9 Or KeyAscii = vbKeyBack Then
        'do nothing
    Else
        KeyAscii = 0    'Disable all other key strokes
    End If

Will that code work on windows vista and windows 7? It can also disable other keys like ALT-Tab or ALT-ESC ?

Yes, it will disable all as per the ascii character set specified. If you want to disable more keys, just add them to the ascii set.

:D okay. Thanks

No problem...

@Abu, please mark this as solved, thanks.:)

x = SystemParametersInfo(97, 1, CStr(1), 0) 'Disable Ctrl+Alt+Del Keys combination

"

I will not answer on this thread, it is a hijacked post. Pito, please read our posting rules.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.