RealtimeCmd – hotkey for running cmd.exe in realtime priority

Sometimes your system hangs because some process enters a busy-loop that does evil things, like allocating huge amounts of memory and causing the swapfile manager to make Windows crawl. In those cases it would be nice to have something that runs in high priority that can kill the offending process. Microsoft addressed this by running winlogon.exe and taskmgr.exe in “High” priority, but that’s just not enough…

RealtimeCmd is a simple program that runs in “Realtime” process priority, idle thread priority (thus lower than any other realtime process, but higher than any non-realtime process) and waits for the hotkey Ctrl-Shift-Alt-WinKey-C (*) (use both hands!). When the hotkey happens, it spawns cmd.exe, in realtime process priority.

Source code ; Compiled exe

Important note: Due to the behavior of the CreateProcess function, programs you run in cmd normally will have Normal priority class. To get them to have Realtime priority class, use the “start” command, i.e.: “start /realtime pskill iexplore” instead of just “pskill iexplore”.

Now I’ll explain how to install it as a Windows service, using the Windows Resource Kit tools instsrv.exe and srvany.exe. (These don’t come with Windows – you have to install the resource kit tools from the Windows CD or from the web.)


C:\Misc>instsrv RealtimeCmd [...]
    [...] "C:\Program Files\Windows Resource Kits\Tools\srvany.exe"

The service was successfuly added!

Make sure that you go into the Control Panel and use
the Services applet to change the Account Name and
Password that this newly installed service will use
for its Security Context.

C:\Misc>reg add [...]
    [...] HKLM\SYSTEM\CurrentControlSet\Services\RealtimeCmd\Parameters [...]
    [...] /v Application /d C:\Misc\Tools\RealtimeCmd.exe
The operation completed successfully.

C:\Misc>reg add HKLM\System\CurrentControlSet\Services\RealtimeCmd [...]
    [...] /v Type /t REG_DWORD /d 0x110
Value Type exists, overwrite(Yes/No)? y
The operation completed successfully.

C:\Misc>reg query [...]
    [...] HKLM\SYSTEM\CurrentControlSet\Services\RealtimeCmd

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RealtimeCmd
    Type    REG_DWORD    0x110
    Start    REG_DWORD    0x2
    ErrorControl    REG_DWORD    0x1
    ImagePath    REG_EXPAND_SZ    C:\Program Files\Windows Resource Kits\Tools\srvany.exe
    DisplayName    REG_SZ    RealtimeCmd
    ObjectName    REG_SZ    LocalSystem

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RealtimeCmd\Parameters
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RealtimeCmd\Security

C:\Misc>reg query [...]
    [...] HKLM\SYSTEM\CurrentControlSet\Services\RealtimeCmd\Parameters

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RealtimeCmd\Parameters
    Application    REG_SZ    C:\Misc\Tools\RealtimeCmd.exe

(*) I was going to use Esc+Ctrl+Tab+Alt+Both Shifts+Num Lock+~, but it was already taken.

About these ads

6 Responses to RealtimeCmd – hotkey for running cmd.exe in realtime priority

  1. Skywing says:

    You need to get a multiproc box; helps -so- much with those annoying runaway programs…

  2. crog says:

    crog hit reset button

    with club

  3. Anonymous says:

    i can not download this package (or compiled exe) any more
    is there a mirror ???

    thanks in advance
    micheal
    (megasound1@gmail.com)

  4. Thanks for finally talking about >RealtimeCmd – hotkey for
    running cmd.exe in realtime priority | The Zero Flag <Liked it!

  5. That is very fascinating, You are an excessively skilled
    blogger. I have joined your rss feed and sit up for searching for more of your fantastic post.

    Also, I have shared your website in my social networks

  6. You’re so cool! I don’t believe I have read through anything like that
    before. So wonderful to discover another person with original
    thoughts on this topic. Really.. thank you for starting this up.
    This site is something that is required on the web, someone with some originality!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: