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

    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


C:\Misc>reg query [...]
    [...] HKLM\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

3 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

Leave a Reply

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

You are commenting using your 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


Get every new post delivered to your Inbox.

%d bloggers like this: