fix: Respect shortcut settings in legacy Windows installs (#1932)

This commit is contained in:
Kroese
2026-07-21 20:52:13 +02:00
committed by GitHub
parent 742f0bddee
commit c2f73db036
+219 -180
View File
@@ -794,6 +794,11 @@ legacyInstall() {
local desc="$3" local desc="$3"
local driver="$4" local driver="$4"
local drivers="/tmp/drivers" local drivers="/tmp/drivers"
local shortcut="Y"
if disabled "$SHORTCUT" || disabled "${SAMBA:-Y}"; then
shortcut="N"
fi
if [ -n "$DOMAIN" ]; then if [ -n "$DOMAIN" ]; then
error "The DOMAIN variable is not supported for $desc!" error "The DOMAIN variable is not supported for $desc!"
@@ -913,11 +918,13 @@ legacyInstall() {
else else
key="${pid:$((${#pid})) - 8:5}" key="${pid:$((${#pid})) - 8:5}"
if [[ "${pid^^}" == *"OEM" ]]; then if [[ "${pid^^}" == *"OEM" ]]; then
key=$(grep -i -A 2 "$key" "$file" | tail -n 2 | head -n 1) || key="" key=$(grep -i -A 2 "$key" "$file" | tail -n 2 | head -n 1) || key=""
else else
key=$(grep -i -m 1 -A 2 "$key" "$file" | tail -n 2 | head -n 1) || key="" key=$(grep -i -m 1 -A 2 "$key" "$file" | tail -n 2 | head -n 1) || key=""
fi fi
key="${key#*= }" key="${key#*= }"
fi fi
@@ -940,7 +947,8 @@ legacyInstall() {
else else
# Windows XP Professional x64 generic trial key (no activation) # Windows XP Professional x64 generic trial key (no activation)
KEY="B2RBK-7KPT9-4JP6X-QQFWM-PJD6G" KEY="B2RBK-7KPT9-4JP6X-QQFWM-PJD6G"
fi ;; fi
;;
"2k3" ) "2k3" )
@@ -950,7 +958,8 @@ legacyInstall() {
else else
# Windows Server 2003 Standard x64 generic trial key (no activation) # Windows Server 2003 Standard x64 generic trial key (no activation)
KEY="P4WJG-WK3W7-3HM8W-RWHCK-8JTRY" KEY="P4WJG-WK3W7-3HM8W-RWHCK-8JTRY"
fi ;; fi
;;
esac esac
@@ -959,6 +968,7 @@ legacyInstall() {
fi fi
fi fi
fi fi
fi fi
@@ -1011,208 +1021,237 @@ legacyInstall() {
find "$target" -maxdepth 1 -type f -iname winnt.sif -delete || return 1 find "$target" -maxdepth 1 -type f -iname winnt.sif -delete || return 1
{ echo "[Data]" {
echo " AutoPartition=1" printf '%s\n' \
echo " MsDosInitiated=\"0\"" '[Data]' \
echo " UnattendedInstall=\"Yes\"" ' AutoPartition=1' \
echo " AutomaticUpdates=\"Yes\"" ' MsDosInitiated="0"' \
echo "" ' UnattendedInstall="Yes"' \
echo "[Unattended]" ' AutomaticUpdates="Yes"' \
echo " UnattendSwitch=Yes" '' \
echo " UnattendMode=FullUnattended" '[Unattended]' \
echo " FileSystem=NTFS" ' UnattendSwitch=Yes' \
echo " OemSkipEula=Yes" ' UnattendMode=FullUnattended' \
echo " OemPreinstall=Yes" ' FileSystem=NTFS' \
echo " Repartition=Yes" ' OemSkipEula=Yes' \
echo " WaitForReboot=\"No\"" ' OemPreinstall=Yes' \
echo " DriverSigningPolicy=\"Ignore\"" ' Repartition=Yes' \
echo " NonDriverSigningPolicy=\"Ignore\"" ' WaitForReboot="No"' \
printf '%s\n' " OemPnPDriversPath=\"Drivers\viostor;Drivers\NetKVM;Drivers\sata\"" ' DriverSigningPolicy="Ignore"' \
echo " NoWaitAfterTextMode=1" ' NonDriverSigningPolicy="Ignore"' \
echo " NoWaitAfterGUIMode=1" ' OemPnPDriversPath="Drivers\viostor;Drivers\NetKVM;Drivers\sata"' \
echo " FileSystem=ConvertNTFS" ' NoWaitAfterTextMode=1' \
echo " ExtendOemPartition=0" ' NoWaitAfterGUIMode=1' \
echo " Hibernation=\"No\"" ' FileSystem=ConvertNTFS' \
echo "" ' ExtendOemPartition=0' \
echo "[GuiUnattended]" ' Hibernation="No"' \
echo " OEMSkipRegional=1" '' \
echo " OemSkipWelcome=1" '[GuiUnattended]' \
echo " AdminPassword=\"$sifPassword\"" ' OEMSkipRegional=1' \
echo " TimeZone=0" ' OemSkipWelcome=1' \
" AdminPassword=\"$sifPassword\"" \
' TimeZone=0'
if disabled "$AUTOLOGIN"; then if disabled "$AUTOLOGIN"; then
echo " AutoLogon=No" printf '%s\n' ' AutoLogon=No'
else else
echo " AutoLogon=Yes" printf '%s\n' \
echo " AutoLogonCount=65432" ' AutoLogon=Yes' \
' AutoLogonCount=65432'
fi fi
echo ""
echo "[UserData]" printf '%s\n' \
echo " FullName=\"$sifUsername\"" '' \
echo " ComputerName=\"$sifHost\"" '[UserData]' \
echo " OrgName=\"$sifOrganization\"" " FullName=\"$sifUsername\"" \
echo " $product" " ComputerName=\"$sifHost\"" \
echo "" " OrgName=\"$sifOrganization\"" \
echo "[Identification]" " $product" \
echo " JoinWorkgroup = \"$sifWorkgroup\"" '' \
echo "" '[Identification]' \
echo "[Display]" " JoinWorkgroup = \"$sifWorkgroup\"" \
echo " BitsPerPel=32" '' \
echo " XResolution=$WIDTH" '[Display]' \
echo " YResolution=$HEIGHT" ' BitsPerPel=32' \
echo "" " XResolution=$WIDTH" \
echo "[Networking]" " YResolution=$HEIGHT" \
echo " InstallDefaultComponents=Yes" '' \
echo "" '[Networking]' \
echo "[Branding]" ' InstallDefaultComponents=Yes' \
echo " BrandIEUsingUnattended=Yes" '' \
echo "" '[Branding]' \
echo "[URL]" ' BrandIEUsingUnattended=Yes' \
echo " Home_Page = http://www.google.com" '' \
echo " Search_Page = http://www.google.com" '[URL]' \
echo "" ' Home_Page = http://www.google.com' \
echo "[TerminalServices]" ' Search_Page = http://www.google.com' \
echo " AllowConnections=1" '' \
echo "" '[TerminalServices]' \
' AllowConnections=1' \
''
} | unix2dos > "$target/WINNT.SIF" || return 1 } | unix2dos > "$target/WINNT.SIF" || return 1
if [[ "$driver" == "2k3" ]]; then if [[ "$driver" == "2k3" ]]; then
{ echo "[Components]" {
echo " TerminalServer=On" printf '%s\n' \
echo "" '[Components]' \
echo "[LicenseFilePrintData]" ' TerminalServer=On' \
echo " AutoMode=PerServer" '' \
echo " AutoUsers=5" '[LicenseFilePrintData]' \
echo "" ' AutoMode=PerServer' \
' AutoUsers=5' \
''
} | unix2dos >> "$target/WINNT.SIF" || return 1 } | unix2dos >> "$target/WINNT.SIF" || return 1
fi fi
{ echo "Windows Registry Editor Version 5.00" {
echo "" printf '%s\n' \
echo "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security]" 'Windows Registry Editor Version 5.00' \
echo "\"FirstRunDisabled\"=dword:00000001" '' \
echo "\"UpdatesDisableNotify\"=dword:00000001" '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security]' \
echo "\"FirewallDisableNotify\"=dword:00000001" '"FirstRunDisabled"=dword:00000001' \
echo "\"AntiVirusDisableNotify\"=dword:00000001" '"UpdatesDisableNotify"=dword:00000001' \
echo "" '"FirewallDisableNotify"=dword:00000001' \
echo "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wscsvc]" '"AntiVirusDisableNotify"=dword:00000001' \
echo "\"Start\"=dword:00000004" '' \
echo "" '[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wscsvc]' \
echo "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List]" '"Start"=dword:00000004' \
echo "\"3389:TCP\"=\"3389:TCP:*:Enabled:@xpsp2res.dll,-22009\"" '' \
echo "" '[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List]' \
echo "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Tour]" '"3389:TCP"="3389:TCP:*:Enabled:@xpsp2res.dll,-22009"' \
echo "\"RunCount\"=dword:00000000" '' \
echo "" '[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Tour]' \
echo "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]" '"RunCount"=dword:00000000' \
echo "\"HideFileExt\"=dword:00000000" '' \
echo "" '[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]' \
echo "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer]" '"HideFileExt"=dword:00000000' \
echo "\"NoWelcomeScreen\"=\"1\"" '' \
echo "" '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer]' \
echo "[HKEY_CURRENT_USER\Software\Microsoft\Internet Connection Wizard]" '"NoWelcomeScreen"="1"' \
echo "\"Completed\"=\"1\"" '' \
echo "\"Desktopchanged\"=\"1\"" '[HKEY_CURRENT_USER\Software\Microsoft\Internet Connection Wizard]' \
echo "" '"Completed"="1"' \
echo "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]" '"Desktopchanged"="1"' \
'' \
'[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]'
if disabled "$AUTOLOGIN"; then if disabled "$AUTOLOGIN"; then
echo "\"AutoAdminLogon\"=\"0\"" printf '%s\n' '"AutoAdminLogon"="0"'
else else
echo "\"AutoAdminLogon\"=\"1\"" printf '%s\n' \
echo "\"DefaultUserName\"=\"$regUsername\"" '"AutoAdminLogon"="1"' \
echo "\"DefaultPassword\"=\"$regPassword\"" "\"DefaultUserName\"=\"$regUsername\"" \
echo "\"DefaultDomainName\"=\"Dockur\"" "\"DefaultPassword\"=\"$regPassword\"" \
'"DefaultDomainName"="Dockur"'
fi fi
echo ""
printf '%s\n' "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\{23A77BF7-ED96-40EC-AF06-9B1F4867732A}\0000]" printf '%s\n' \
echo "\"DefaultSettings.BitsPerPel\"=dword:00000020" '' \
echo "\"DefaultSettings.XResolution\"=dword:$XHEX" '[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\{23A77BF7-ED96-40EC-AF06-9B1F4867732A}\0000]' \
echo "\"DefaultSettings.YResolution\"=dword:$YHEX" '"DefaultSettings.BitsPerPel"=dword:00000020' \
echo "" "\"DefaultSettings.XResolution\"=dword:$XHEX" \
printf '%s\n' "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Control\VIDEO\{23A77BF7-ED96-40EC-AF06-9B1F4867732A}\0000]" "\"DefaultSettings.YResolution\"=dword:$YHEX" \
echo "\"DefaultSettings.BitsPerPel\"=dword:00000020" '' \
echo "\"DefaultSettings.XResolution\"=dword:$XHEX" '[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Control\VIDEO\{23A77BF7-ED96-40EC-AF06-9B1F4867732A}\0000]' \
echo "\"DefaultSettings.YResolution\"=dword:$YHEX" '"DefaultSettings.BitsPerPel"=dword:00000020' \
echo "" "\"DefaultSettings.XResolution\"=dword:$XHEX" \
echo "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce]" "\"DefaultSettings.YResolution\"=dword:$YHEX" \
printf '%s\n' "\"ScreenSaver\"=\"reg add \\\"HKCU\\\\Control Panel\\\\Desktop\\\" /f /v \\\"SCRNSAVE.EXE\\\" /t REG_SZ /d \\\"off\\\"\"" '' \
printf '%s\n' "\"ScreenSaverOff\"=\"reg add \\\"HKCU\\\\Control Panel\\\\Desktop\\\" /f /v \\\"ScreenSaveActive\\\" /t REG_SZ /d \\\"0\\\"\"" '[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce]' \
printf '%s\n' "\"SharedDrive\"=\"cmd /C net use Z: \\\\\\\\host.lan\\\\Data /persistent:yes\"" '"ScreenSaver"="reg add \"HKCU\\Control Panel\\Desktop\" /f /v \"SCRNSAVE.EXE\" /t REG_SZ /d \"off\""' \
echo "$oem" '"ScreenSaverOff"="reg add \"HKCU\\Control Panel\\Desktop\" /f /v \"ScreenSaveActive\" /t REG_SZ /d \"0\""'
echo ""
if enabled "$shortcut"; then
printf '%s\n' '"SharedDrive"="cmd /C net use Z: \\\\host.lan\\Data /persistent:yes"'
fi
printf '%s\n' "$oem" ''
} | unix2dos > "$dir/\$OEM\$/install.reg" || return 1 } | unix2dos > "$dir/\$OEM\$/install.reg" || return 1
if [[ "$driver" == "2k" ]]; then if [[ "$driver" == "2k" ]]; then
{ echo "[HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Runonce]" {
echo "\"^SetupICWDesktop\"=-" printf '%s\n' \
echo "" '[HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Runonce]' \
'"^SetupICWDesktop"=-' \
''
} | unix2dos >> "$dir/\$OEM\$/install.reg" || return 1 } | unix2dos >> "$dir/\$OEM\$/install.reg" || return 1
fi fi
if [[ "$driver" == "2k3" ]]; then if [[ "$driver" == "2k3" ]]; then
{ echo "[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\srvWiz]" {
echo "@=dword:00000000" printf '%s\n' \
echo "" '[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\srvWiz]' \
echo "[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\ServerOOBE\SecurityOOBE]" '@=dword:00000000' \
echo "\"DontLaunchSecurityOOBE\"=dword:00000000" '' \
echo "" '[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\ServerOOBE\SecurityOOBE]' \
'"DontLaunchSecurityOOBE"=dword:00000000' \
''
} | unix2dos >> "$dir/\$OEM\$/install.reg" || return 1 } | unix2dos >> "$dir/\$OEM\$/install.reg" || return 1
fi fi
{ echo "Set WshShell = WScript.CreateObject(\"WScript.Shell\")" {
echo "Set WshNetwork = WScript.CreateObject(\"WScript.Network\")" printf '%s\n' \
echo "Set Domain = GetObject(\"WinNT://\" & WshNetwork.ComputerName)" 'Set WshShell = WScript.CreateObject("WScript.Shell")' \
echo "" 'Set WshNetwork = WScript.CreateObject("WScript.Network")' \
echo "Function DecodeSID(binSID)" 'Set Domain = GetObject("WinNT://" & WshNetwork.ComputerName)' \
echo " ReDim o(LenB(binSID))" '' \
echo "" 'Function DecodeSID(binSID)' \
echo " For i = 1 To LenB(binSID)" ' ReDim o(LenB(binSID))' \
echo " o(i-1) = AscB(MidB(binSID, i, 1))" '' \
echo " Next" ' For i = 1 To LenB(binSID)' \
echo "" ' o(i-1) = AscB(MidB(binSID, i, 1))' \
echo " sid = \"S-\" & CStr(o(0)) & \"-\" & OctetArrayToString _" ' Next' \
echo " (Array(o(2), o(3), o(4), o(5), o(6), o(7)))" '' \
echo " For i = 8 To (4 * o(1) + 4) Step 4" ' sid = "S-" & CStr(o(0)) & "-" & OctetArrayToString _' \
echo " sid = sid & \"-\" & OctetArrayToString _" ' (Array(o(2), o(3), o(4), o(5), o(6), o(7)))' \
echo " (Array(o(i+3), o(i+2), o(i+1), o(i)))" ' For i = 8 To (4 * o(1) + 4) Step 4' \
echo " Next" ' sid = sid & "-" & OctetArrayToString _' \
echo "" ' (Array(o(i+3), o(i+2), o(i+1), o(i)))' \
echo " DecodeSID = sid" ' Next' \
echo "End Function" '' \
echo "" ' DecodeSID = sid' \
echo "Function OctetArrayToString(arr)" 'End Function' \
echo " v = 0" '' \
echo " For i = 0 To UBound(arr)" 'Function OctetArrayToString(arr)' \
echo " v = v * 256 + arr(i)" ' v = 0' \
echo " Next" ' For i = 0 To UBound(arr)' \
echo "" ' v = v * 256 + arr(i)' \
echo " OctetArrayToString = CStr(v)" ' Next' \
echo "End Function" '' \
echo "" ' OctetArrayToString = CStr(v)' \
echo "For Each DomainItem in Domain" 'End Function' \
echo " If DomainItem.Class = \"User\" Then" '' \
echo " sid = DecodeSID(DomainItem.Get(\"objectSID\"))" 'For Each DomainItem in Domain' \
echo " If Left(sid, 9) = \"S-1-5-21-\" And Right(sid, 4) = \"-500\" Then" ' If DomainItem.Class = "User" Then' \
echo " LocalAdminADsPath = DomainItem.ADsPath" ' sid = DecodeSID(DomainItem.Get("objectSID"))' \
echo " Exit For" ' If Left(sid, 9) = "S-1-5-21-" And Right(sid, 4) = "-500" Then' \
echo " End If" ' LocalAdminADsPath = DomainItem.ADsPath' \
echo " End If" ' Exit For' \
echo "Next" ' End If' \
echo "" ' End If' \
echo "Call Domain.MoveHere(LocalAdminADsPath, \"$username\")" 'Next' \
echo "" '' \
echo "Set oLink = WshShell.CreateShortcut(WshShell.SpecialFolders(\"Desktop\") & \"\\Shared.lnk\")" "Call Domain.MoveHere(LocalAdminADsPath, \"$username\")" \
echo "With oLink" ''
printf '%s\n' " .TargetPath = \"\\\\host.lan\\Data\""
echo " .Save" if enabled "$shortcut"; then
echo "End With" printf '%s\n' \
echo "Set oLink = Nothing" 'Set oLink = WshShell.CreateShortcut(WshShell.SpecialFolders("Desktop") & "\Shared.lnk")' \
echo "" 'With oLink' \
' .TargetPath = "\\host.lan\Data"' \
' .Save' \
'End With' \
'Set oLink = Nothing' \
''
fi
} | unix2dos > "$dir/\$OEM\$/install.vbs" || return 1 } | unix2dos > "$dir/\$OEM\$/install.vbs" || return 1
{ echo "[COMMANDS]" {
echo "\"REGEDIT /s install.reg\"" printf '%s\n' \
echo "\"Wscript install.vbs\"" '[COMMANDS]' \
echo "" '"REGEDIT /s install.reg"' \
'"Wscript install.vbs"' \
''
} | unix2dos > "$dir/\$OEM\$/cmdlines.txt" || return 1 } | unix2dos > "$dir/\$OEM\$/cmdlines.txt" || return 1
return 0 return 0