Read registry value and reboot and resume

Got a problem you cannot solve? Try here.
Balanced-Plus
Posts: 31
Joined: Sat Aug 28, 2010 9:06 pm
Contact:

Read registry value and reboot and resume

Postby Balanced-Plus » Mon Sep 11, 2023 11:09 pm

Hi,

To solve issues when installing SQL Server media on Windows 11 systems I want to read a registry value before Pre-requisite SQL Server Media is installed.
If the value is not available or incorrect it should be added to the registry (ONLY when the SQL instance isn't already installed).
The system needs to be rebooted in order to activate the new value (before installing SQL Server).
Background info: https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/database-file-operations/troubleshoot-os-4kb-disk-sector-size

The code basically looks like the following.

Code: Select all

    Set Variable WIZZ_FORCE_SECTORSIZE_WIN11 to
    Set x64 - Native 64 bit Windows, AMD64 and EM64T Architectures - installation mode
    Comment: Registry uitlezen t.b.v. installatie SQL Server op Windows 11 systemen.
    Read Registry Key HKLM\SYSTEM\CurrentControlSet\Services\stornvme\Parameters\Device\ForcedPhysicalSectorSizeInBytes into WIZZ_FORCE_SECTORSIZE_WIN11
    if Variable WIZZ_FORCE_SECTORSIZE_WIN11 not Equals * 4095
      Comment: Registry waarde toevoegen t.b.v. installatie SQL Server op Windows 11 systemen.
      Write Registry Key HKLM\SYSTEM\ControlSet001\Services\stornvme\Parameters\Device\ForcedPhysicalSectorSizeInBytes, * 4095 (permanent)
      Reboot Computer and Resume Setup
    end


Will it work if I add the section to the "Check SQL Instance"-script (like below)?

Code: Select all

Set Variable ISWINDOWS64BIT to FALSE
Set Variable WIZZ_FORCE_SECTORSIZE_WIN11 to
Get System Setting Windows in 64 bit Mode into ISWINDOWS64BIT
if Variable ISWINDOWS64BIT Equals TRUE
 Set x64 - Native 64 bit Windows, AMD64 and EM64T Architectures - installation mode
 Check Service State for MSSQL$BALANCEDPLUS2008 (write result into variable MSSQL2022_X64)
 if Variable MSSQL2022_X64 Equals NOTINSTALLED
[b]   Comment: Registry uitlezen t.b.v. installatie SQL Server op Windows 11 systemen.
   Read Registry Key HKLM\SYSTEM\CurrentControlSet\Services\stornvme\Parameters\Device\ForcedPhysicalSectorSizeInBytes into WIZZ_FORCE_SECTORSIZE_WIN11
   if Variable WIZZ_FORCE_SECTORSIZE_WIN11 not Equals * 4095
     Comment: Registry waarde toevoegen t.b.v. installatie SQL Server op Windows 11 systemen.
     Write Registry Key HKLM\SYSTEM\ControlSet001\Services\stornvme\Parameters\Device\ForcedPhysicalSectorSizeInBytes, * 4095 (permanent)
     Reboot Computer and Resume Setup
   end
[/b]   Get System Setting Windows 8 into MSSQL2022_IS8_X64
   if Variable MSSQL2022_IS8_X64 Equals FALSE
     
     Set Variable OS_SP to
     Get System Setting Windows 2008 R2 into MSSQL2022_IS2008R2_X64
     Get System Setting Windows 2008 into MSSQL2022_IS2008_X64
     Get System Setting Windows 7 into MSSQL2022_ISSEVEN_X64
     
     if Variable MSSQL2022_IS2008R2_X64 Equals TRUE
       Comment: For Win 2008 R2, at least Service Pack 1 is required
       Get System Setting Service Pack 1 into OS_SP
       if Variable OS_SP Equals FALSE
         MessageBox: $TITLE$ Setup, $TITLE$ requires at least Service Pack 1 or later. Please upgrade your operating system and try again.$NEWLINE$$NEWLINE$$TITLE$ Setup cannot continue.
         Terminate Installation
       end
       else
       if Variable MSSQL2022_IS2008_X64 Equals TRUE
         Comment: For Win 2008, at least Service Pack 2 is required
         Get System Setting Service Pack 2 into OS_SP
         if Variable OS_SP Equals FALSE
           MessageBox: $TITLE$ Setup, $TITLE$ requires at least Service Pack 2 or later. Please upgrade your operating system and try again.$NEWLINE$$NEWLINE$$TITLE$ Setup cannot continue.
           Terminate Installation
         end
         else
         if Variable MSSQL2022_ISSEVEN_X64 Equals TRUE
           Comment: For Win 7, at least Service Pack 1 is required
           Get System Setting Service Pack 1 into OS_SP
           if Variable OS_SP Equals FALSE
             MessageBox: $TITLE$ Setup, $TITLE$ requires at least Service Pack 1 or later. Please upgrade your operating system and try again.$NEWLINE$$NEWLINE$$TITLE$ Setup cannot continue.
             Terminate Installation
           end
           else
           Comment: at least Windows 7 is required
           MessageBox: $TITLE$ Setup, $TITLE$ requires at Windows 7 sp1 or later. Please upgrade your operating system and try again.$NEWLINE$$NEWLINE$$TITLE$ Setup cannot continue.
           Terminate Installation
         end
       end
     end
   end
   
   Set Variable MSSQL2022_X64 to FALSE
   Set Variable PREREQ to TRUE
   Set Variable PRELIST to $PRELIST$$NEWLINE$Microsoft SQL Server Express 2022 (x64)
   else
   Set Variable MSSQL2022_X64 to TRUE
 end
 Set Win32 - Native 32 bit Windows and Windows 32 on Windows 64 (WOW64) - installation mode
 else
 MessageBox: $TITLE$ Setup, $TITLE$ requires a 64 bit operating system. Please upgrade your operating system and try again.$NEWLINE$$NEWLINE$$TITLE$ Setup cannot continue.
 Terminate Installation
end

Thanks for your help.

JohnGaver
Posts: 80
Joined: Mon Feb 05, 2024 6:15 pm

Re: Read registry value and reboot and resume

Postby JohnGaver » Mon Feb 12, 2024 7:11 pm

What happens when you run the code?
John Gaver
InstallAware Skunkworks
InstallAware Multi Platform - Liberating DEB/RPM/PKG/MSI(X) into universal native setups!
Get your free copy today - https://www.installaware.com/installaware-multi-platform.htm

Balanced-Plus
Posts: 31
Joined: Sat Aug 28, 2010 9:06 pm
Contact:

Re: Read registry value and reboot and resume

Postby Balanced-Plus » Tue Feb 13, 2024 6:18 am

My question is more about if someone can look at it if it will work.
Is it added to the right places inside the script?


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 55 guests