Replacing Calc with Calculator Plus
On my home machine, and one of my office machines I log in as a normal user, and only elevate to an account with admin status when installing software, or doing other maintenance. Needless to say, doing that creates problems with various programs that were written to always assume that the user has administrative access to the machine. One of the more surprising programs that has this problem is Windows Calculator.
Good old calc.exe keeps a machine-wide setting to determine if it's in scientific or standard mode. Not only does it have this as a machine-wide setting, but it doesn't even store it in HKLM, instead keeping the setting in win.ini. (Check out SciCalc\layout in win.ini to see for yourself). Obviously normal users don't have write access to win.ini, so any change they make to the calculator setting will not get saved. This is aside from the fact that having a per-machine setting leaves computers with multiple users to fight over which setting gets saved.
My solution? Calculator Plus. Calculator Plus stores its settings in HKCU\Software\Microsoft\CalcPlus, allowing for non-admins to save settings, and for different users to have different sets of settings. Additionally, it is more fully featured than standard calculator.
After installing Calculator Plus, I'd like to use it every time some application on my computer tries to launch calc. Generally, this either is done from the quick launch menu, from the command line, from the start menu, or by using the calc button on my keyboard. The most obvious way to accomplish this is to change all of my shortcuts to point to CalcPlus rather than calc. However, that would get tedious quickly. Another way to do this is to simply copy CalcPlus.exe over the existing calc.exe. This would work, but I generally try to stay away from solutions that involve replacing Windows files, even if they are as trivial as calc.
What I ended up doing is taking advantage of Windows' Image File Execution Options. Windows allows you to specify a debugger for an application, which will always be launched when the application is launched. This allows you to debug applications that aren't easy to start up on your own. However, since Windows will launch the debugger, and its up to the debugger to launch the actual application, you can use this feature to "replace" one program with another. (This is exactly how Process Explorer implements its "Replace Task Manager" feature).
Setting up a debugger for calc can be done in two ways. If you've installed the Debugging Tools for Windows , you can run gflags, and on the image file tab specify "C:\Program Files\Microsoft Calc Plus\CalcPlus.exe" as the debugger for the calc.exe image. If you don't have the debuggers installed, then another option is to add the registry key yourself. Under HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options, add a new key named calc.exe. Under the calc.exe key, add a string value named debugger which has a value of the full path to CalcPlus.exe (remembering quotes if necessary).
Once that's setup, I now have a calc applet that has more features than the standard one, and plays well when running as non-admin as well.
Updated 4:59pm: Added the name of the registry value for the image debugger
Comments
- Anonymous
October 06, 2004
You didn't mention it explicitly, but for those trying this, name the string "debugger" if you add it manually. - Anonymous
October 06, 2004
Good point, I meant to include that in the explanation. Thanks.
-Shawn - Anonymous
October 06, 2004
Ok for calc, but it's not the principal application I'm using.
What about VS? It is pratically impossible to build and debug an ASP application with VS without beeing admin. Yes, I know there is a lot of papers explaining how to do with a normal account (even in MSDN), except that the solution they provide does not work.
When I post in forum for that problem, I've never meet someone successully with that either. So it does not seem to be so obvious.
I even meet a PC where it was impossible to make ASP running in debug mode without giving it system privileges in machine.config ????
VS has a real problem with account privileges, at least something is not clear.
But just for my curiosity, why I should be admin to debug and not just be in the debugger group? If should be admin as well, what is the interest of the debuger group?
thank you - Anonymous
October 07, 2004
Or, there's ProgLauncher. Seems a lot simpler. I use this for my NotePad replacement needs, and it works great.
http://phi.lho.free.fr/softwares/PhiLhoSoft/freewares/index_en.html - Anonymous
October 10, 2004
The comment has been removed - Anonymous
October 15, 2004
The comment has been removed - Anonymous
November 17, 2005
Great FIX. May I write about this on my blog? My intention is to translate some of your post. Naturally i write about you, including the url of your work.
Are you agree? - Anonymous
November 18, 2005
Sure -- go ahead.
-Shawn - Anonymous
November 02, 2006
FYI calc.exe was fixed in Feb 2005 to use HKCU. See, sometimes Windows bugs do get fixed :-)