From a9581c91529ad48b415c23af6ffc2a47b422c56f Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 1 Oct 2022 18:43:44 -0700 Subject: [PATCH 1/2] Update OS version sections to support Windows 11 --- scripts/wk/os/win.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/scripts/wk/os/win.py b/scripts/wk/os/win.py index a7fa6118..16658501 100644 --- a/scripts/wk/os/win.py +++ b/scripts/wk/os/win.py @@ -68,14 +68,24 @@ KNOWN_HIVE_NAMES = { winreg.HKEY_LOCAL_MACHINE: 'HKLM', winreg.HKEY_USERS: 'HKU', } -OS_VERSION = platform.win32_ver()[0] -OS_VERSION = 8.1 if OS_VERSION == '8.1' else int(OS_VERSION) RAM_OK = 5.5 * 1024**3 # ~6 GiB assuming a bit of shared memory RAM_WARNING = 3.5 * 1024**3 # ~4 GiB assuming a bit of shared memory REG_MSISERVER = r'HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\MSIServer' SLMGR = pathlib.Path(f'{os.environ.get("SYSTEMROOT")}/System32/slmgr.vbs') SYSTEMDRIVE = os.environ.get('SYSTEMDRIVE') +# STATIC OS VARIABLES +WIN32_VER = platform.win32_ver() +OS_BUILD_VERSION_FULL = WIN32_VER[1] +OS_BUILD_VERSION = int(OS_BUILD_VERSION_FULL.split('.')[2]) +PLATFORM_VER = WIN32_VER[0] +if PLATFORM_VER == '8.1': + OS_VERSION = 8.1 +elif OS_BUILD_VERSION >= 22000: + OS_VERSION = 11 +else: + OS_VERSION = int(PLATFORM_VER) + # Activation Functions def activate_with_bios(): @@ -267,21 +277,19 @@ def get_os_name(as_list=False, check=True): outdated or unsupported. """ key = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion' - build_version = int(reg_read_value("HKLM", key, "CurrentBuild")) - build_version_full = platform.win32_ver()[1] - details = WINDOWS_BUILDS.get(build_version_full, f'Build {build_version}') + details = WINDOWS_BUILDS.get(OS_BUILD_VERSION_FULL, f'Build {OS_BUILD_VERSION}') display_name = ( f'{reg_read_value("HKLM", key, "ProductName")} {ARCH}-bit {details}' ) - if build_version >= 22000: + if OS_BUILD_VERSION >= 22000: display_name = display_name.replace('Windows 10', 'Windows 11') # Check for support issues if check: - if build_version in OUTDATED_BUILD_NUMBERS: + if OS_BUILD_VERSION in OUTDATED_BUILD_NUMBERS: raise GenericWarning(f'{display_name} (outdated)') - if build_version < OLDEST_SUPPORTED_BUILD: + if OS_BUILD_VERSION < OLDEST_SUPPORTED_BUILD: raise GenericError(f'{display_name} (unsupported)') # Done From 591fb8e138e8f17342caf60543b1a06d88fe4dc9 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 1 Oct 2022 19:15:15 -0700 Subject: [PATCH 2/2] Skip installing Open Shell under Windows 11 --- scripts/wk/cfg/setup.py | 5 +++++ scripts/wk/setup/win.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/scripts/wk/cfg/setup.py b/scripts/wk/cfg/setup.py index 97d0bd5a..1b49897d 100644 --- a/scripts/wk/cfg/setup.py +++ b/scripts/wk/cfg/setup.py @@ -10,6 +10,11 @@ BROWSER_PATHS = { 'Microsoft Edge': 'Microsoft/Edge/Application/msedge.exe', 'Opera': 'Opera/launcher.exe', } +DISABLED_ENTRIES_WINDOWS_11 = { + # Group Name: Option Name + 'Install Software': 'Open Shell', + 'Configure System': 'Open Shell', + } LIBREOFFICE_XCU_DATA = ''' Impress MS PowerPoint 2007 XML diff --git a/scripts/wk/setup/win.py b/scripts/wk/setup/win.py index c399b0c6..40ebb512 100644 --- a/scripts/wk/setup/win.py +++ b/scripts/wk/setup/win.py @@ -12,6 +12,7 @@ import sys from wk.cfg.main import KIT_NAME_FULL from wk.cfg.setup import ( BROWSER_PATHS, + DISABLED_ENTRIES_WINDOWS_11, LIBREOFFICE_XCU_DATA, REG_CHROME_UBLOCK_ORIGIN, REG_WINDOWS_EXPLORER, @@ -162,6 +163,11 @@ def build_menus(base_menus, title, presets): MENU_PRESETS.add_action('Quit') MENU_PRESETS.update() + # Disable entries incompatible with Windows 11 + if OS_VERSION == 11: + for group_name, entry_name in DISABLED_ENTRIES_WINDOWS_11.items(): + menus[group_name].options[entry_name]['Disabled'] = True + # Done return menus