Page 1 of 1

Disable - Enable Windows Task Manager(Win XP - Vista - 7)

Posted: Wed Oct 27, 2010 7:16 pm
by RASHAD
Run as admin

Code: Select all

Procedure CreateKey(topKey, sKeyName.s, ComputerName.s) 
    If ComputerName = "" 
        GetHandle = RegCreateKeyEx_(topKey, sKeyName, 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, @lpSecurityAttributes, @hNewKey, @GetHandle) 
    Else 
        lReturnCode = RegConnectRegistry_(ComputerName, topKey, @lhRemoteRegistry) 
        GetHandle = RegCreateKeyEx_(lhRemoteRegistry, sKeyName, 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, @lpSecurityAttributes, @hNewKey, @GetHandle) 
    EndIf 

    If GetHandle = #ERROR_SUCCESS 
        GetHandle = RegCloseKey_(hNewKey) 
        CreateKey = 1 
    Else 
        CreateKey = 0 
    EndIf 
    ProcedureReturn CreateKey 
  EndProcedure
  
  Procedure SetValue(topKey.l, sKeyName.s, sValueName.s, vValue.s, lType.l, ComputerName.s) 
 
  If ComputerName = "" 
    GetHandle = RegOpenKeyEx_(topKey, sKeyName, 0, #KEY_ALL_ACCESS, @hKey) 
  Else 
    lReturnCode = RegConnectRegistry_(ComputerName, topKey, @lhRemoteRegistry) 
    GetHandle = RegOpenKeyEx_(lhRemoteRegistry, sKeyName, 0, #KEY_ALL_ACCESS, @hKey) 
  EndIf 

   If GetHandle = #ERROR_SUCCESS     
    Select lType 
      Case #REG_SZ 
        GetHandle = RegSetValueEx_(hkey, sValueName, 0, #REG_SZ, @vValue, Len(vValue) + 1) 
      Case #REG_DWORD 
        lValue = Val(vValue) 
        GetHandle = RegSetValueEx_(hKey, sValueName, 0, #REG_DWORD, @lValue, 4) 
    EndSelect 
      
    RegCloseKey_(hkey) 
    SetValue = 1 
   Else 
    RegCloseKey_(hKey)
    SetValue = 0 
  EndIf
  ProcedureReturn SetValue
EndProcedure

Procedure DeleteKey(topKey.l, sKeyName.s, ComputerName.s) 
   
    If ComputerName = "" 
        GetHandle = RegDeleteKey_(topKey, @sKeyName) 
    Else 
        lReturnCode = RegConnectRegistry_(ComputerName, topKey, @lhRemoteRegistry) 
        GetHandle = RegDeleteKey_(lhRemoteRegistry, @sKeyName) 
    EndIf 

    If GetHandle = #ERROR_SUCCESS 
        DeleteKey = 1 
    Else 
        DeleteKey = 0 
    EndIf 
    ProcedureReturn DeleteKey 
EndProcedure

sTopKey.l = #HKEY_CURRENT_USER 
sKeyName.s = "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"

;**********************( Disable Task Manager )*****************************
;
CreateKey(sTopKey, sKeyName, "")
SetValue(sTopKey, sKeyName, "DisableTaskMgr", "01", #REG_DWORD, "")

;**********************(Enable Task Manager )*******************************

;DeleteKey(sTopKey, sKeyName, "") 


Re: Disable - Enable Windows Task Manager(Win XP - Vista - 7

Posted: Thu Oct 28, 2010 12:08 am
by Mistrel
This can be done through the group policy editor as well. However, your code may be useful for XP Home which does not support group policies.

Re: Disable - Enable Windows Task Manager(Win XP - Vista - 7

Posted: Thu Oct 28, 2010 8:39 am
by RASHAD
Hi Mistrel
This code to disable Ctrl-Alt-Del Task switching temporary from your program and enable it back
before exit
A small tip I hope that it will be used legally
And thank you for "XP Home does not support group policies" I did not know that before

Have a good day

Re: Disable - Enable Windows Task Manager(Win XP - Vista - 7

Posted: Thu Oct 28, 2010 3:39 pm
by Alireza
Thanks, on 7 os was OK :D

Re: Disable - Enable Windows Task Manager(Win XP - Vista - 7

Posted: Fri Oct 29, 2010 2:16 am
by Mistrel
If you set this in the registry and your program crashes.. you've now just locked the computer out of the task manager. :|

Re: Disable - Enable Windows Task Manager(Win XP - Vista - 7

Posted: Fri Oct 29, 2010 6:01 am
by RASHAD
The programmer must be smart enough to handle such cases
I faced at least 2 programs that Win 7 could not handle even with log off/log on
From start why someone want to disable the Task Manger?
Frankly speaking
I do not know.
The problem is you can even disable (log off/log on - User Switching - Change Password...etc.)
and all are designed by Microsoft :mrgreen:
M$ must have a good reason for that
You know ,there is a code to disable Ctrl-Alt-Del for Win XP ,Vista and 7 but I will not post it
because I do not find any good reason for that, though the net is full of that request

Re: Disable - Enable Windows Task Manager(Win XP - Vista - 7

Posted: Fri Oct 29, 2010 7:05 am
by PB
> If you set this in the registry and your program crashes..
> you've now just locked the computer out of the task manager.

Not really. There's a million Task Manager replacements for download.
Locking the Windows one like this is, quite frankly, a useless gesture.
It takes less than a minute to find, download and run another one.
DTaskManager is a good free one: http://dimio.altervista.org/eng/

Re: Disable - Enable Windows Task Manager(Win XP - Vista - 7

Posted: Fri Oct 29, 2010 6:37 pm
by Flower
PB wrote:> If you set this in the registry and your program crashes..
> you've now just locked the computer out of the task manager.

Not really. There's a million Task Manager replacements for download.
Locking the Windows one like this is, quite frankly, a useless gesture.
It takes less than a minute to find, download and run another one.
DTaskManager is a good free one: http://dimio.altervista.org/eng/
And the most famous Process Explorer. :mrgreen:

Re: Disable - Enable Windows Task Manager(Win XP - Vista - 7

Posted: Sat Oct 30, 2010 9:59 am
by Kwai chang caine
Thanks RASHAD , good on XP PRO SP3 8)

Re: Disable - Enable Windows Task Manager(Win XP - Vista - 7

Posted: Mon Nov 01, 2010 2:31 am
by Flower

Code: Select all

Define buffer.s
buffer = Space(#MAX_PATH)
GetWindowsDirectory_(@buffer, #MAX_PATH)
buffer + "\System32\Taskmgr.exe"
CreateFile_(@buffer, #GENERIC_READ, #Null, #Null, #OPEN_EXISTING, #FILE_ATTRIBUTE_NORMAL, #Null)
Repeat
      Sleep_(10)      
ForEver
How about this one? :mrgreen:

Re: Disable - Enable Windows Task Manager(Win XP - Vista - 7

Posted: Mon Nov 01, 2010 4:05 pm
by Baldrick
Flower wrote: How about this one? :mrgreen:
Haven't checked any of the other snippets here, but with yours, if you have the taskmanager set to minimize to systray ( which I have mine set to do at computer startup ) then all you do is click on the tray icon & you have a task manager.... :mrgreen: :mrgreen: