changeset 33204:d8fbfa44b064 stable

Avoid error during startup check on old versions of Windows. * scripts/startup/site-rcfile: Avoid error on old versions of Windows 10 where the registry key that indicates the used console host did not exist yet.
author Markus Mützel <markus.muetzel@gmx.de>
date Thu, 14 Mar 2024 08:06:08 +0100
parents 0f9fe0289e9b
children ccd0c0eaa323 c82ac458cd78
files scripts/startup/site-rcfile
diffstat 1 files changed, 28 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/startup/site-rcfile	Sat Mar 09 11:05:41 2024 +0100
+++ b/scripts/startup/site-rcfile	Thu Mar 14 08:06:08 2024 +0100
@@ -6,19 +6,33 @@
 ## This file contains commands that should be executed each time Octave starts
 ## for every user at this site.
 
-if ispc () && isguirunning () ...
-    && ~strcmp (winqueryreg ("HKEY_CURRENT_USER", 'Console\%%Startup', "DelegationConsole"), ...
-                "{B23D10C0-E52E-411E-9D5B-C09FDF709C7D}")
-  warn_str = ["WARNING: You are using an incompatible Windows configuration!\n", ...
-              "Microsoft's new Terminal App is not compatible with Octave.\n", ...
-              "Please follow the instructions on the following page and set the ", ...
-              "default terminal to \"Windows Console Host\":\n", ...
-              "https://octave.discourse.group/t/4981/"];
-  warning ("octave:terminal-app", warn_str);
-  answer = questdlg ([warn_str, "\n\nWould you like to open that page in your browser?"], ...
-                     "Incompatible Configuration", "Yes", "No", "Yes");
-  if strcmp (answer, "Yes")
-    system ("start https://octave.discourse.group/t/4981/");
+if (ispc () && isguirunning ())
+  try
+    is_windows_console_host = ...
+      strcmp (winqueryreg ("HKEY_CURRENT_USER", 'Console\%%Startup', "DelegationConsole"), ...
+              "{B23D10C0-E52E-411E-9D5B-C09FDF709C7D}");
+  catch
+    ## The above might fail for old versions of Windows 10 where that
+    ## registry key didn't exist.  Assume that the Windows Console Host
+    ## is being used in this case.
+    is_windows_console_host = true;
+  end_try_catch
+
+  if (! is_windows_console_host)
+    warn_str = ["WARNING: You are using an incompatible Windows configuration!\n", ...
+                "Microsoft's new Terminal App is not compatible with Octave.\n", ...
+                "Please follow the instructions on the following page and set the ", ...
+                "default terminal to \"Windows Console Host\":\n", ...
+                "https://octave.discourse.group/t/4981/"];
+    warning ("octave:terminal-app", warn_str);
+    answer = questdlg ([warn_str, "\n\nWould you like to open that page in your browser?"], ...
+                       "Incompatible Configuration", "Yes", "No", "Yes");
+    if (strcmp (answer, "Yes"))
+      system ("start https://octave.discourse.group/t/4981/");
+    endif
+    clear warn_str answer
   endif
-  clear warn_str answer
+
+  clear is_windows_console_host
+
 endif