Open calc.exe in a specific mode via menu or arg

Not for Windows 10 or above:

Windows 10 has replaced the old calc.exe with a new one which doesn't work in the same way, so this script will just launch the new calculator on Windows 10 without changing modes.

If you're on Windows 10 or above, this old post is now only useful for seeing how to do things with scripts in Opus:

  • Add a custom command with argument template
  • Show a pop-up menu of choices
  • Run another program
  • Read and modify the Windows registry


This scripts adds a new command to Opus: LaunchCalc

The LaunchCalc command opens the Windows Calculator (calc.exe) directly into one of its four modes:

  • Standard
  • Scientific
  • Programmer
  • Statistics.

(The script does this by modifying the registry setting calc.exe uses to store the last-used mode.)


  • Does not work at all with Windows 10's re-written "Metro" calc.exe.

  • In Windows 7, for the script to work, the account you're using must have launched calc.exe and changed its mode at least once. The script works by modifying a registry setting and will only modify it if exists already (which happens the first time you change modes). The script won't create the registry setting if it's not already there, in case calc.exe changes where it stores the setting in the future. (And, indeed, it did change.)

  • The script may fail and do nothing on Windows XP because old versions of calc.exe stored the mode in win.ini instead of the registry.


  • Download LaunchCalc.vbs.txt (4.0 KB)
  • Open Preferences / Toolbars / Scripts and drag the file to the list.


Once installed, a new LaunchCalc command will be available in the Button Editor, Hotkey Editor, and so on.

If you run LaunchCalc without any arguments, it will show a pop-up menu where you can select the mode you want calc.exe to use:

You can also tell the command which mode you want to bypass the menu and launch calc.exe directly into a specific mode:

  • LaunchCalc MODE=standard
  • LaunchCalc MODE=scientific
  • LaunchCalc MODE=programmer
  • LaunchCalc MODE=statistics

For example, if you often find yourself needing the scientific and programmer modes, you might want to set up a pair of system-wide hotkeys so that you can push one key from any app to open a scientific calc.exe, and another key to open a programmer calc.exe. (Alternatively, don't specify a mode and use just one hotkey, so that when you push the hotkey a menu appears and you can choose from that.)

The script itself:

The script code is reproduced here so that people looking for scripting techniques on the forum can browse the script code without having to download anything.

Option Explicit

' Calculator Launcher
' (c) 2014 Leo Davidson
' This is a script for Directory Opus.
' See for development information.
' This script adds a LaunchCalc command to Opus.
' The LaunchCalc command can open the Windows Calculator (calc.exe) directly into one of its four modes
' (Standard, Scientific, Programmer and Statistics). You can tell the command to open in a particular mode,
' using a command-line argument, or you can let it display a pop-up menu.

' Called by Directory Opus to initialize the script
Function OnInit(initData)
	' Provide basic information about the Script = "Calculator Launcher"
	initData.desc = "Open calc.exe in a specified mode."
	initData.copyright = "(c) 2014 Leo Davidson"
	initData.default_enable = true

	' Initialise the command that this script adds
	Dim cmd
	Set cmd = initData.AddCommand() = "LaunchCalc"
	cmd.method = "OnLaunchCalc"
	cmd.desc = initData.desc
	cmd.label = "Launch Calculator"
	cmd.template = "MODE/O[<ask>,standard,scientific,programmer,statistics]"
End Function

' Helper function
Function AddMenuFlags(vecFlags, val, test)
	If (val = test) Then
		vecFlags.push_back 1
		vecFlags.push_back 0
	End If
End Function

' Implements the LaunchCalc command
Function OnLaunchCalc(scriptCmdData)

	Const REG_VALUE_PATH_CALC_LAYOUT = "HKCU\Software\Microsoft\Calc\layout"

	Dim objShell
	Dim layoutValue
	Dim layoutNewValue
	Dim dlgChoice
	Dim objDlg
	Dim vecChoices
	Dim vecCValues
	Dim vecMenu
	Dim numValues
	Dim i

	Set objShell = CreateObject("WScript.Shell")

	' Always read the current layout value, so that if the registry settings aren't there the script will fail.
	' (They were not in the registry at all on Windows XP, and could be moved again in the future.)
	layoutValue = objShell.RegRead(REG_VALUE_PATH_CALC_LAYOUT)

	layoutNewValue = -1

	' See if a mode was specified via the MODE argument.
	If ( scriptCmdData.func.args.got_arg.mode ) Then
		If (scriptCmdData.func.args.mode = "standard") Then
			layoutNewValue = CALC_LAYOUT_STANDARD
		ElseIf (scriptCmdData.func.args.mode = "scientific") Then
		ElseIf (scriptCmdData.func.args.mode = "programmer") Then
		ElseIf (scriptCmdData.func.args.mode = "statistics") Then
		End If
	End If

	' If we don't now which mode we want, use a pop-up menu to ask the user.
	If (layoutNewValue < 0) Then

		Set vecChoices = DOpus.NewVector
		Set vecCValues = DOpus.NewVector
		Set vecMenu    = DOpus.NewVector
		vecChoices.push_back "&Standard"
		vecCValues.push_back CALC_LAYOUT_STANDARD
		vecChoices.push_back "S&cientific"
		vecCValues.push_back CALC_LAYOUT_SCIENTIFIC
		vecChoices.push_back "&Programmer"
		vecCValues.push_back CALC_LAYOUT_PROGRAMMER
		vecChoices.push_back "S&tatistics"
		vecCValues.push_back CALC_LAYOUT_STATISTICS
		vecChoices.push_back "-"
		vecChoices.push_back "Cancel"
		' Make the item for the last used mode bold.
		For i = 0 To vecCValues.size - 1
			AddMenuFlags vecMenu, layoutValue, vecCValues(i)

		Set objDlg = scriptCmdData.func.Dlg
		objDlg.choices = vecChoices = vecMenu
		dlgChoice = objDlg.Show()

		dlgChoice = dlgChoice - 1 ' Convert to 0-based index, -1 meaning nothing was selected.

		If (dlgChoice < 0 Or dlgChoice >= vecCValues.size) Then
			layoutNewValue = -1
			layoutNewValue = vecCValues(dlgChoice)
		End If

	End If

	' If we now know the mode to use, launch calc.exe, changing the registry value first if needed.
	If (layoutNewValue > -1) Then
		If (layoutValue <> layoutNewValue) Then
			objShell.RegWrite REG_VALUE_PATH_CALC_LAYOUT, layoutNewValue, "REG_DWORD"
		End If
		objShell.Run "%windir%\system32\calc.exe", 1, False
	End If

End Function


The script may fail and do nothing if the account you're using has never launched calc.exe before. It makes sure the registry setting it wants to modify already exists before changing it, to avoid creating a mess in the registry should the setting ever move in the future.[/quote]

It definitely fails in Windows 7 unless HKCU\Software\Microsoft\Calc contains a DWORD entry named layout. Once this has been created manually, it works perfectly.

Regards, AB

It should contain that once you launch and exit calc once, so I think that's the same as what I said.

Nope. Launching and exiting calc.exe did not create a layout registry entry, at least not on my work W7 system or the W7 VM I just tried it in.

Regards, AB

Maybe you have to change modes once as well or something. It definitely works here.

Yes, changing modes seems to be the trigger. Just opening and closing is not sufficient.

Regards, AB

can't get this to work with 11.13 on Windows 10 preview, any clues?


In what way doesn't it work?

jon, if backup/restore from win7 settings then Calc icon shows but doesn't do anything, if install from scratch then no icon shows at all.

Did you see this post? If you've never launched calc.exe before on that machine that could explain it. Check that registry setting exists.

yes saw that and switched calc types then made the mistake of presuming it was in the registry. It's different w win10, looks like it stores stuff here:


oh well...

Windows 10 has a completely new, Metro calculator for some unknown reason. At least that's how current builds are. I am not wasting time on it until the final builds, because it could change again.

Update: It's still there in the final Windows 10, and I have run into so many issues with the Windows 10 calculator (particularly with its broken keyboard support, not taking keyboard focus sometimes even when clicked on, and slow startup) that I'm going to look for a replacement calculator app rather than try to make things work with the Windows 10 one. A lot of other people seem annoyed by the change so maybe Microsoft will fix things with the new one, or let us choose the old one again.