views:

466

answers:

2

I found this code for disabling the task manager in Windows XP. It works :)

But does it work in Windows 7, too? The registry path is the same, I've checked this. But maybe there are some restrictions!?

Thanks in advance!

+2  A: 

By default, the below keys have "readonly" access for standard users since Windows 2000 (See here).

  • HKLM\Software\Policies
  • HKLM\Software\Microsoft\Windows\CurrentVersion\Policies
  • HKCU\Software\Policies
  • HKCU\Software\Microsoft\Windows\CurrentVersion\Policies

So your application needs to have administrative privileges in order to write to these keys.

Sertac Akyuz
Thank you. My question was if it works in Windows 7, too. So is it possible to change those keys in Windows 7 with administrative privileges, too? Or did they block access for those keys in Windows 7?
@marco92w: If the keys exist, I think they can be altered with admin privs. I will try this later tonight.
Andreas Rejbrand
@marco92w - Yes, I did test with a quick app on W7 with the "DisableTaskMgr", if "run as administrator", TRegistry successfully writes the key and the value and task manager is effectively disabled.
Sertac Akyuz
But on Windows 7, programms seem to be firstly executed as a normal user without administrative privileges, right? This is a difference to Windows XP - and exactly what I wanted to know. :)
Yes, if UAC is enabled (which is the default state), even when an admin is logged on, the applications are ran in the context of a standard user, unless "run as administrator" is selected, or the application requires administrative privileges by means of a manifest for instance. In either case a dialog is shown before the app is ran, asking for affirmation.
Sertac Akyuz
+1  A: 

Yes, it works in Windows 7 too. I ran the program with raised privileges (Windows 7 Home Premium), and after that the Task Manager is no longer available.

But, as a sidenote, I have to say that the code

case YesNo of
  False:
    begin
      WriteInteger('DisableTaskMgr',1) ;
    end;
  True:
    begin
      WriteInteger('DisableTaskMgr',0) ;
    end;
end;

is rather horrible. First of all, there is no need at all for the begin and end parts, because the commands WriteInteger... are "one-liners". Secondly, why not just write the value of not YesNo?

One really should write the code as

WriteInteger('DisableTaskMgr', byte(not YesNo));

Isn't that much more readable and brief?

Andreas Rejbrand
Thank you very very much, Andreas! What a great optimization! A 10-line code block made to a simple 1-liner ...