Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6036661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:57:27+00:00 2026-05-23T05:57:27+00:00

I would like to create a palette for switching .NB-file associations between installed versions

  • 0

I would like to create a palette for switching .NB-file associations between installed versions of Mathematica under Windows.

At this moment I have developed the following code for enumerating installed versions of Mathematica and switching between them:

1) Getting list of names of system registry keys of installed versions of Mathematica:

installedVersions = 
 Select[Developer`EnumerateRegistrySubkeys["HKEY_CLASSES_ROOT"], 
  StringMatchQ[#, "Mathematica.NB." ~~ ___] || # === 
     "MathematicaNB" &]

=> {"Mathematica.NB.7.0.1.1213965", "MathematicaNB"}

2) Function that adds command line options -b (disables the splash screen) and -directlaunch (disables the mechanism which launches the most recent Mathematica version installed) to the command line string for launching Mathematica FrontEnd in the system registry:

customizeOpenCommand[id_String] := Module[{value},
   value = 
    Cases[Developer`ReadRegistryKeyValues[
      "HKEY_CLASSES_ROOT\\" ~~ id ~~ "\\shell\\open\\command"], 
     Verbatim[Rule][Null, 
       val_String /; 
        StringFreeQ[val, " -b -directlaunch "]] :> (Null -> 
        StringReplace[val, 
         path__ ~~ "\\Mathematica.exe\"" ~~ __ ~~ "\"%1\"" :> 
          path ~~ "\\Mathematica.exe\" -b -directlaunch \"%1\""])];
   Developer`WriteRegistryKeyValues[
    "HKEY_CLASSES_ROOT\\" ~~ id ~~ "\\shell\\open\\command", value]];

This function can be used as follows:

customizeOpenCommand /@ installedVersions

3) Function for getting current .NB-file association:

Null /. Developer`ReadRegistryKeyValues["HKEY_CLASSES_ROOT\\.nb"]

4) Buttons for switching between all Mathematica versions installed (but I think it probably could be implemented better using Dynamic and SetterBar):

Column[Button[
    Row[{"Associate .NB-files with ", Style[#, Bold], " (", 
      First@Cases[
        Developer`ReadRegistryKeyValues["HKEY_CLASSES_ROOT\\" ~~ #], 
        Verbatim[Rule][Null, str_String] :> str], ")"}], 
    Developer`WriteRegistryKeyValues["HKEY_CLASSES_ROOT\\.nb", 
     Null -> #], Alignment -> Left] & /@ installedVersions]

In addition to the above here is the command which disables sharing of preferences between different Mathematica versions installed (by default all installed versions use one file for storing the FrontEnd settings):

SetOptions[$FrontEnd, "VersionedPreferences" -> True]

So my problem is:

How to create and install a small Palette which will dynamically display the current file associations for .NB-files and will allow to switch between them by clicking a button? I think it probably can be implemented just with SetterBar but I still unexperienced with Dynamic and palette creation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:57:28+00:00Added an answer on May 23, 2026 at 5:57 am

    Up to this moment I have come to the following solution:

    CreatePalette@
      Framed[DynamicModule[{b, installedVersions}, 
        Dynamic[Column[
          Join[{Style["Associate .NB-files with:", Bold], 
            SetterBar[
             Dynamic[val, 
              Function[{v, e}, 
               Developer`WriteRegistryKeyValues["HKEY_CLASSES_ROOT\\.nb", 
                Null -> v]; 
               e = Null /. 
                 Developer`ReadRegistryKeyValues[
                  "HKEY_CLASSES_ROOT\\.nb"], HoldRest], 
              Initialization -> (installedVersions = 
                 Select[Developer`EnumerateRegistrySubkeys[
                   "HKEY_CLASSES_ROOT"], 
                  StringMatchQ[#, "Mathematica.NB." ~~ ___] || # === 
                     "MathematicaNB" &]; 
                If[StringFreeQ[
                    value = 
                     Null /. 
                      Developer`ReadRegistryKeyValues[
                       "HKEY_CLASSES_ROOT\\" ~~ # ~~ 
                        "\\shell\\open\\command"], " -b -directlaunch "], 
                   Developer`WriteRegistryKeyValues[
                    "HKEY_CLASSES_ROOT\\" ~~ # ~~ 
                     "\\shell\\open\\command", 
                    Null -> 
                     StringReplace[value, 
                      path__ ~~ "\\Mathematica.exe\"" ~~ __ ~~ "\"%1\"" :>
                        path ~~ 
                        "\\Mathematica.exe\" -b -directlaunch \"%1\""]]] \
    & /@ installedVersions)], installedVersions, 
             Appearance -> "Vertical"]}, 
           If[Last@Last@Options[$FrontEnd, "VersionedPreferences"] === 
              False && 
             b == True, {Button[
              Pane[Style[
                "This FrontEnd uses shared preferences file. Press this \
    button to set FrontEnd to use versioned preferences file (all the \
    FrontEnd settings will be reset to defaults).", Red], 300], 
              AbortProtect[
               SetOptions[$FrontEnd, "VersionedPreferences" -> True]; 
               b = False]]}, {}]], Alignment -> Center], 
         Initialization :> 
          If[! Last@Last@Options[$FrontEnd, "VersionedPreferences"], 
           b = True, b = False]]], FrameMargins -> {{0, 0}, {0, 5}}, 
       FrameStyle -> None];
    

    This palette can be installed permanently using “Install Palette…” menu item in “Palette” menu.

    Here is how it looks:

    screenshot1 screenshot2

    Any suggestions and improvements are welcome!


    Since all installed versions of Mathematica share the same $BaseDirectory and $UserBaseDirectory, it is recommended to install this palette in the oldest version installed to avoid standard warning popup:

    This notebook was created in a more recent version of Mathematica, and
    may not function properly with the older front end you are using.
    Contact Wolfram Research (www.wolfram.com) for upgrade information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like create alarm clock at windows phone 7 mango , for this
I would like to create this shape using just css. I am pretty sure
I would like to create multiple objects/instances in a loop. how to do this?
I would like to create a main overview chart with asp:chart control, like this:
i would like create a menu with kdialog like this kdialog --menu choose your
i would like create a array of structure which have a dynamic array :
I would like to create a c++ type that mimic the build-in type exactly.
I would like to create a json object to send as a post array,
I would like to create set of strings and below is the only limitation.
I would like to create a class that runs something (a runnable) at regular

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.