Removing or disabling Chrome’s Task Manager with a batch-file

2

1

I am trying to find a way to either disable or completely remove Chrome’s Task Manager.

My proposed solution involves using a batch-file running in the background to detect if the Chrome Task Manager is open, and shut down Chrome if it is. Unfortunately, I do not know batch programming and am low on time for this problem to be solved.

Here’s a couple of ideas I had for this:

  • This command detects how many instances of Chrome are running:

    tasklist /nh /fi "imagename eq chrome.exe" | find /i "chrome.exe" >nul && (wmic process where name="chrome.exe" | find "chrome.exe" /c

  • This command kills all Chrome processes:

    taskkill /im chrome.exe

This does not work because Chrome does not create a new process when the Task Manager is opened, though it does create a new window. (There is no change in the Processes tab of the Windows Task Manager, but there is one in the Tasks tab.)

I will settle for a program that shuts down Chrome if it detects two windows of it open, even partial solutions are welcome at this point.

user278048

Posted 2013-11-29T23:46:30.630

Reputation:

let me guess you want to block users from closing tabs/visiting there own sites – ratchet freak – 2013-11-29T23:51:02.707

I bet it is some manager's new "wonderful" idea. – NothingsImpossible – 2013-11-29T23:55:38.840

It is for me and it's on my own PC. A very long and uninteresting story lies behind this. – None – 2013-11-30T00:00:54.957

2this somehow screams XY problem – ratchet freak – 2013-11-30T00:03:23.270

1Then don't regard it as such and solve the original problem. I inserted pieces of my proposed solution because it increased the chances of someone solving it. – None – 2013-11-30T00:07:51.980

3@user1472696 It's still somewhat XY, because we do not know why you want to disable the task manager. It sounds like disabling the task manager is an attempted solution to a different problem, rather than the actual end goal. If that is the case, then we may be able to help find an alternative method. (Also, I do not see how disabling the task manager would help in any way at all...) – Bob – 2013-11-30T01:42:07.420

Answers

0

This should get you some of the way there.

For detecting if Task Manager is open - use something like this:

tasklist /fi "WINDOWTITLE eq Task Manager - Google Chrome" /v | find "chrome.exe"

In a batch file you will probably need to escape the pipe character:

tasklist /fi "WINDOWTITLE eq Task Manager - Google Chrome" /v ^| find "chrome.exe"

Then use an %ERRORLEVEL% check to see if you it found it and kill them all:

if "%ERRORLEVEL%" == "1" TASKKILL /IM chrome.exe /F

I'll leave you to loop in batch (consider adding a sleep too).

Dean Taylor

Posted 2013-11-29T23:46:30.630

Reputation: 103

0

It would be better to merely close the Chrome Task Manager window rather than killing the whole browser, which seems to be your goal anyway.

If you’re not committed to a batch-file, then an easy way to accomplish this is to use an AutoHotkey script:

;Script paramters
#SingleInstance, force
#Persistent
SetBatchLines, -1
Process, Priority,, High

;Set up window hook
Gui +LastFound
hWnd:=WinExist()
DllCall("RegisterShellHookWindow", UInt,hWnd)
MsgNum:=DllCall("RegisterWindowMessage", Str,"SHELLHOOK")
OnMessage(MsgNum, "ShellMessage")
HSHELL_WINDOWCREATED:=1
Return

;Hook function
ShellMessage(wParam,lParam)
{
    if (wParam=HSHELL_WINDOWCREATED)               ;Window created
    {
        WinGetTitle, Title, ahk_id %lParam%        ;Get window title
        if  (Title="Task Manager - Google Chrome") ;Check if Chrome Task Manager
            WinClose, ahk_id %lParam%              ;Close it
    }
}

(Of course if you are looking for security and trying to lock the browser down, then this is not the right way to go. Unfortunately I’m not sure that Chrome natively supports a secure lock-down mode.)

Synetech

Posted 2013-11-29T23:46:30.630

Reputation: 63 242

Someone contacted me today about this not working. I did a quick test and it did indeed not work (though I stopped using Chrome a few years ago, so my quick sandboxed test installation may not have been perfect). In any case, if it doesn't work, you can try running AHK as admin, or try setting it to Windows XP/7 compatability in case Windows 10 is the problem. Failing that, it's likely Google simply changed Chrome too much and did things in their own, non-standard, incompatible, non–user-friendly, unusable ways, as usual. – Synetech – 2019-09-20T19:03:51.067

Possibly some kiosk mode? Though that might be far more restrictive than simply the task manager. – Bob – 2013-11-30T01:22:55.963

@Bob, one would think so, but the Task Manager still works even in kiosk mode, at least for the Chrome browser on a PC (I just tried it), I don’t know about on a Chromebook. – Synetech – 2013-11-30T01:26:17.627

Synetech, I cannot express my gratitude great enough. It simply.. works. – None – 2013-11-30T01:45:30.970

@Synetech Pity. Anyway, you might want to amend your script to use WinWait instead - I'm not sure if it would be more or less efficient than polling in a loop, but it will certainly feel cleaner. – Bob – 2013-11-30T02:10:50.347

Actually, looks like ShellHook is even better for resource usage - no polling at all. – Bob – 2013-11-30T03:31:40.503

@Bob, unfortunately AutoHotkey does not currently support a proper window-creation trigger yet, so hacks like this are necessary. WinWait is one of the options I considered, and I even looked at some hooks to actually trigger on window creation, but the hooks use large libraries, and WinWait still has to run in a loop. That said, I agree that WinWait should at least avoid the Sleep. I’ll do a quick test and update.

– Synetech – 2013-11-30T05:23:47.450

Most solutions for this sort of thing do indeed require a loop. :-( However here’s a promising little hook that should hopefully be able to run the script to close the window before it is even displayed. I’ll test it as well. – Synetech – 2013-11-30T05:27:43.073

Yup, the hook from the SO and AHK forums works like a charm. Now it does nothing until the Task Manager window is created instead of checking for it in a loop. Also, when it does get created, it is closed much faster. (Yay! Now I can clean up all the AHK window-creation-hook scripts I’ve collected but not had a chance to test.) Again, this works well enough, but it’s not foolproof. For real security, unfortunately you need to either convince the Google devs to implement a secure mode for Chrome for use a different browser. – Synetech – 2013-11-30T21:41:18.170