From c7b5abb0bcfab1f0c17783d9e5a32a37ff2f906b Mon Sep 17 00:00:00 2001 From: Alan Mason <1923621+2Shirt@users.noreply.github.com> Date: Fri, 24 Nov 2017 20:48:55 -0800 Subject: [PATCH] 2015-12: Retroactive Updates --- WK/Notepad2.ini | 27 ++++------- WK/Scripts/WK.ps1 | 87 +++++++++++++++++++++++++--------- WK/Scripts/init.ps1 | 10 ++-- WK/config.xml | 112 ++++++++++++++++++++++++++++++++++++++++++++ WK/hwmonitorw.ini | 1 + make-cd.cmd | 2 +- make.cmd | 57 ++++++++++++---------- update.cmd | 100 --------------------------------------- 8 files changed, 227 insertions(+), 169 deletions(-) create mode 100644 WK/config.xml delete mode 100644 update.cmd diff --git a/WK/Notepad2.ini b/WK/Notepad2.ini index 6bba42de..4522220d 100644 --- a/WK/Notepad2.ini +++ b/WK/Notepad2.ini @@ -95,7 +95,7 @@ ShellUseSystemMRU=1 15=#B000B0 16=#B28B40 [Styles] -Use2ndDefaultStyle=1 +Use2ndDefaultStyle=0 DefaultScheme=0 AutoSelect=1 SelectDlgSizeX=304 @@ -113,19 +113,12 @@ SelectDlgSizeY=324 2nd Caret (Color, Size 1-3)=fore:#C0C0C0 2nd Long Line Marker (Colors)=fore:#404040 2nd Extra Line Spacing (Size)= -[Window] -1440x900 PosX=600 -1440x900 PosY=16 -1440x900 SizeX=824 -1440x900 SizeY=824 -1440x900 Maximized=1 -1600x900 PosX=756 -1600x900 PosY=16 -1600x900 SizeX=828 -1600x900 SizeY=828 -1600x900 Maximized=1 -800x600 PosX=216 -800x600 PosY=16 -800x600 SizeX=568 -800x600 SizeY=568 -800x600 Maximized=0 \ No newline at end of file +[Recent Files] +01= +02= +[Recent Find] +01= +02= +[Recent Replace] +01= +02= diff --git a/WK/Scripts/WK.ps1 b/WK/Scripts/WK.ps1 index ccfcd28b..9fc55b6b 100644 --- a/WK/Scripts/WK.ps1 +++ b/WK/Scripts/WK.ps1 @@ -154,7 +154,7 @@ function mount-servers { # Mount servers wk-write "Connecting to backup server(s)" foreach ($_server in $backup_servers) { - if (test-connection $_server.ip -count 1 -quiet) { + if (test-connection $_server.ip -count 1 -quiet 2>&1 | out-null) { try { $_path = "\\{0}\{1}" -f $_server.ip, $_server.path $_drive = "{0}:" -f $_server.letter @@ -195,39 +195,79 @@ function menu-imaging { pause ## WARNING + # Check if any source drives were detected + $disks = get-disk | where {$_.Size -ne 0} +# if ($disks.count -eq 0) { +# wk-error "No suitable source drives were detected." +# pause "Press Enter to return to main menu... " $True +# return 1 +# } + # Mount server(s) mount-servers - # Select destination + # Build server menu $avail_servers = @(gdr | where {$_.DisplayRoot -imatch '\\\\'}) - $menu_disc_imaging = "Which drive are we imaging?`r`n`r`n" +# if ($avail_servers.count -eq 0) { +# wk-error "No suitable backup servers were detected." +# pause "Press Enter to return to main menu... " $True +# return 1 +# } + $menu_imaging_server = "Where are we saving the backup image(s)?`r`n`r`n" $valid_answers = @("M", "m") for ($i=0; $i -lt $avail_servers.length; $i++) { $valid_answers += ($i + 1) - $menu_disc_imaging += ("{0}: {1} ({2:N2} Gb free)`r`n" -f ($i + 1), $avail_servers[$i].Description, ($avail_servers[$i].Free / 1Gb)) + $menu_imaging_server += ("{0}: {1} ({2:N2} Gb free)`r`n" -f ($i + 1), $avail_servers[$i].Description, ($avail_servers[$i].Free / 1Gb)) } - $menu_disc_imaging += "`r`n" - $menu_disc_imaging += "M: Main Menu`r`n" - $menu_disc_imaging += "`r`n" - $menu_disc_imaging += "Please make a selection`r`n" + $menu_imaging_server += "`r`n" + $menu_imaging_server += "M: Main Menu`r`n" + $menu_imaging_server += "`r`n" + $menu_imaging_server += "Please make a selection`r`n" + + # Select server do { - clear - $answer = read-host -prompt $menu_disc_imaging +##testing## clear + $answer = read-host -prompt $menu_imaging_server } until ($valid_answers -contains $answer) if ($answer -imatch '^M$') { # Exit if requested unmount-servers - popd return } else { $answer -= 1 $dest_backup_server = $avail_servers[$answer] } + # Build source menu + $menu_imaging_source = "For which drive are we creating backup image(s)?`r`n`r`n" + $valid_answers = @("M", "m") + foreach ($_ in $disks) { + $valid_answers += $_.DiskNumber + $menu_imaging_source += "{0}: {1:N0} Gb`t({2}) {3} ({4})`r`n" -f $_.DiskNumber, ($_.Size / 1GB), $_.BusType, $_.FriendlyName, $_.PartitionStyle + } + $menu_imaging_source += "`r`n" + $menu_imaging_source += "M: Main Menu`r`n" + $menu_imaging_source += "`r`n" + $menu_imaging_source += "Please make a selection`r`n" + + # Select source + do { +##testing## clear + $answer = read-host -prompt $menu_imaging_source + } until ($valid_answers -contains $answer) + + if ($answer -imatch '^M$') { + # Exit if requested + return + } else { + ##TODO## + get-volume + } + # Service Order $menu_service_order += "Please enter the service order`r`n" do { - clear +##testing## clear $service_order = read-host -prompt $menu_service_order } until ($service_order -imatch '^\d[\w\-]+$') @@ -242,7 +282,14 @@ function menu-imaging { function menu-setup { wk-write "Windows Setup" wk-write "" - pushd $WKPath\Setup + + # Check if any destination drives were detected + $disks = get-disk | where {$_.Size -ne 0 -and $_.BusType -inotmatch 'USB'} + if ($disks.count -eq 0) { + wk-error "No suitable destination drives were detected." + pause "Press Enter to return to main menu... " $True + return 1 + } # Build windows menu $windows_versions = @( @@ -267,13 +314,12 @@ function menu-setup { # Select Windows version do { - clear +##testing## clear $answer = read-host -prompt $menu_setup_windows } until ($valid_answers -contains $answer) if ($answer -imatch '^M$') { # Exit if requested - popd return } else { $answer -= 1 @@ -283,7 +329,6 @@ function menu-setup { # Build disk menu $menu_setup_disk = "To which drive are we installing {0}?`r`n`r`n" -f $dest_windows_version.Name $valid_answers = @("M", "m") - $disks = get-disk | where {$_.Size -ne 0 -and $_.BusType -inotmatch 'USB'} foreach ($_ in $disks) { $valid_answers += $_.DiskNumber $menu_setup_disk += "{0}: {1:N0} Gb`t({2}) {3}`r`n" -f $_.DiskNumber, ($_.Size / 1GB), $_.PartitionStyle, $_.FriendlyName @@ -295,13 +340,12 @@ function menu-setup { # Select disk do { - clear +##testing## clear $answer = read-host -prompt $menu_setup_disk } until ($valid_answers -contains $answer) if ($answer -imatch '^M$') { # Exit if requested - popd return } else { # Double check before deleting data @@ -365,13 +409,12 @@ function menu-setup { pause "Press Enter to return to main menu... " } } - popd } function menu-tools { wk-write "Misc Tools" wk-write "" wk-warn "Be careful." - start "explorer" -argumentlist @("$WKPath\Programs") + start "$WKPath\explorer++" -argumentlist @("$WKPath") wk-exit } function menu-main { @@ -391,10 +434,10 @@ Please make a selection "@ do { - clear +##testing## clear $answer = read-host -prompt $menu_main } until ($answer -imatch '^[123QRS]$') - clear +##testing## clear if ($answer.GetType().Name -match "String") { $answer = $answer.ToUpper() diff --git a/WK/Scripts/init.ps1 b/WK/Scripts/init.ps1 index 6fbb9bcd..e0065430 100644 --- a/WK/Scripts/init.ps1 +++ b/WK/Scripts/init.ps1 @@ -3,7 +3,7 @@ # Some common settings and functions $host.UI.RawUI.BackgroundColor = "black" -$host.UI.RawUI.ForegroundColor = "green" +$host.UI.RawUI.ForegroundColor = "cyan" $systemdrive = (gci env:systemdrive).value $WKPath = "$systemdrive\WK" $date = get-date -uformat "%Y-%m-%d" @@ -42,7 +42,11 @@ function wk-write { out-file -filepath $log -inputobject $text -append } function pause { - param([string]$message = "Press Enter to continue... ") - write-host $message + param([string]$message = "Press Enter to continue... ", [bool]$warning = $False) + if ($warning) { + write-host ($message) -foreground "yellow" + } else { + write-host ($message) + } $x = read-host } diff --git a/WK/config.xml b/WK/config.xml new file mode 100644 index 00000000..90a19145 --- /dev/null +++ b/WK/config.xml @@ -0,0 +1,112 @@ + + + + + yes + no + yes + yes + no + yes + no + no + + + + + 90 + yes + no + no + no + no + no + no + 0 + yes + 9 + no + 0 + yes + no + ::{20D04FE0-3AEA-1069-A2D8-08002B30309D} + no + 500 + yes + yes + 1 + yes + no + no + no + yes + yes + yes + yes + no + yes + no + yes + yes + yes + no + yes + yes + no + yes + yes + yes + 1 + yes + 1 + yes + no + no + + no + 208 + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WK/hwmonitorw.ini b/WK/hwmonitorw.ini index 0bfb23e7..e3978b4e 100644 --- a/WK/hwmonitorw.ini +++ b/WK/hwmonitorw.ini @@ -4,4 +4,5 @@ USE_ACPI=1 USE_SMBUS=1 USE_SMART=1 USE_DISPLAY=1 +CPU_0_TJMAX=100.0 UPDATES=0 diff --git a/make-cd.cmd b/make-cd.cmd index 500141fc..885ba639 100644 --- a/make-cd.cmd +++ b/make-cd.cmd @@ -13,7 +13,7 @@ for %%f in (%*) do ( :CreateISO del winpe10-test.iso -makewinpemedia.cmd /iso wd winpe10-test.iso +makewinpemedia.cmd /iso pe_files winpe10-test.iso :Abort echo. diff --git a/make.cmd b/make.cmd index 91af52ab..29afdf3a 100644 --- a/make.cmd +++ b/make.cmd @@ -5,6 +5,7 @@ setlocal EnableDelayedExpansion title WinPE 10 creation tool color 1b pushd %~dp0 +set "wd=%cd%" set "winpe_ocs=%programfiles(x86)%\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs" @@ -14,58 +15,62 @@ for %%f in (%*) do ( ) :CopyPEFiles -call copype.cmd amd64 "%cd%\wd" +call copype.cmd amd64 "%wd%\pe_files" :Mount rem echo Press any key to configure the WinPE image... rem pause>nul -mkdir "%cd%\mount" -dism /mount-image /imagefile:"%cd%\wd\media\sources\boot.wim" /index:1 /mountdir:"%cd%\mount" +mkdir "%wd%\mount" +dism /mount-image /imagefile:"%wd%\pe_files\media\sources\boot.wim" /index:1 /mountdir:"%wd%\mount" :AddPackages +mkdir "%wd%\log" + :: More info: https://msdn.microsoft.com/en-us/library/windows/hardware/dn938382(v=vs.85).aspx -dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\WinPE-FMAPI.cab" -dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\WinPE-WMI.cab" -dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\en-us\WinPE-WMI_en-us.cab" +dism /add-package /image:"%wd%\mount" /packagepath:"%winpe_ocs%\WinPE-FMAPI.cab" /logpath:"dism.log" +dism /add-package /image:"%wd%\mount" /packagepath:"%winpe_ocs%\WinPE-WMI.cab" /logpath:"dism.log" +dism /add-package /image:"%wd%\mount" /packagepath:"%winpe_ocs%\en-us\WinPE-WMI_en-us.cab" /logpath:"dism.log" :: Install WinPE-WMI before you install WinPE-NetFX. -dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\WinPE-NetFx.cab" -dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\en-us\WinPE-NetFx_en-us.cab" -dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\WinPE-Scripting.cab" -dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\en-us\WinPE-Scripting_en-us.cab" +dism /add-package /image:"%wd%\mount" /packagepath:"%winpe_ocs%\WinPE-NetFx.cab" /logpath:"dism.log" +dism /add-package /image:"%wd%\mount" /packagepath:"%winpe_ocs%\en-us\WinPE-NetFx_en-us.cab" /logpath:"dism.log" + +:: Install WinPE-WMI > WinPE-NetFX before you install WinPE-Scripting. +dism /add-package /image:"%wd%\mount" /packagepath:"%winpe_ocs%\WinPE-Scripting.cab" /logpath:"dism.log" +dism /add-package /image:"%wd%\mount" /packagepath:"%winpe_ocs%\en-us\WinPE-Scripting_en-us.cab" /logpath:"dism.log" :: Install WinPE-WMI > WinPE-NetFX > WinPE-Scripting before you install WinPE-PowerShell. -dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\WinPE-PowerShell.cab" -dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\en-us\WinPE-PowerShell_en-us.cab" +dism /add-package /image:"%wd%\mount" /packagepath:"%winpe_ocs%\WinPE-PowerShell.cab" /logpath:"dism.log" +dism /add-package /image:"%wd%\mount" /packagepath:"%winpe_ocs%\en-us\WinPE-PowerShell_en-us.cab" /logpath:"dism.log" :: Install WinPE-WMI > WinPE-NetFX > WinPE-Scripting > WinPE-PowerShell before you install WinPE-DismCmdlets. -dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\WinPE-DismCmdlets.cab" -dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\en-us\WinPE-DismCmdlets_en-us.cab" +dism /add-package /image:"%wd%\mount" /packagepath:"%winpe_ocs%\WinPE-DismCmdlets.cab" /logpath:"dism.log" +dism /add-package /image:"%wd%\mount" /packagepath:"%winpe_ocs%\en-us\WinPE-DismCmdlets_en-us.cab" /logpath:"dism.log" :: Install WinPE-WMI > WinPE-NetFX > WinPE-Scripting > WinPE-PowerShell before you install WinPE-SecureBootCmdlets. -dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\WinPE-SecureBootCmdlets.cab" +dism /add-package /image:"%wd%\mount" /packagepath:"%winpe_ocs%\WinPE-SecureBootCmdlets.cab" /logpath:"dism.log" :Robocopy -del "%cd%\WK\Scripts\WK.log" -mkdir "%cd%\mount\WK" -robocopy /e "%cd%\WK" "%cd%\mount\WK" +del "%wd%\WK\Scripts\WK.log" +mkdir "%wd%\mount\WK" +robocopy /e "%wd%\WK" "%wd%\mount\WK" +mklink "%wd%\mount\System32\explorer.exe" "%wd%\mount\WK\Explorer++.exe" :MenuLauncher -copy /y "%cd%\System32\menu.cmd" "%cd%\mount\Windows\System32\menu.cmd" +copy /y "%wd%\System32\menu.cmd" "%wd%\mount\Windows\System32\menu.cmd" :ReplaceStartnet -copy /y "%cd%\System32\startnet.cmd" "%cd%\mount\Windows\System32\startnet.cmd" +copy /y "%wd%\System32\startnet.cmd" "%wd%\mount\Windows\System32\startnet.cmd" :ReplaceNotepad reg load HKLM\WinPE-SW mount\Windows\System32\config\SOFTWARE reg add "HKLM\WinPE-SW\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v Debugger /t REG_SZ /d "X:\WK\Notepad2.exe /z" /f -reg add "HKLM\WinPE-SW\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\explorer.exe" /v Debugger /t REG_SZ /d "X:\WK\Explorer++.exe /z" /f reg unload HKLM\WinPE-SW :Background -takeown /f "%cd%\mount\Windows\System32\winpe.jpg" /a -icacls "%cd%\mount\Windows\System32\winpe.jpg" /grant administrators:F -copy /y "%cd%\System32\winpe.jpg" "%cd%\mount\Windows\System32\winpe.jpg" +takeown /f "%wd%\mount\Windows\System32\winpe.jpg" /a +icacls "%wd%\mount\Windows\System32\winpe.jpg" /grant administrators:F +copy /y "%wd%\System32\winpe.jpg" "%wd%\mount\Windows\System32\winpe.jpg" :ManualStuff echo Now is the time to add stuff (optional). @@ -74,11 +79,11 @@ echo Press any key to commit changes... pause>nul :Unmount -dism /unmount-image /mountdir:"%cd%\mount" /commit +dism /unmount-image /mountdir:"%wd%\mount" /commit :CreateISO del winpe10-test.iso -makewinpemedia.cmd /iso wd winpe10-test.iso +makewinpemedia.cmd /iso "%wd%\pe_files" winpe10-test.iso goto Done :Abort diff --git a/update.cmd b/update.cmd deleted file mode 100644 index 03545b77..00000000 --- a/update.cmd +++ /dev/null @@ -1,100 +0,0 @@ -@echo off - -:Init -setlocal EnableDelayedExpansion -title WinPE 10 update tool -color 1b -pushd %~dp0 -set "winpe_ocs=%programfiles(x86)%\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs" - - -:Flags -for %%f in (%*) do ( - if /i "%%f" == "/DEBUG" (@echo on) -) - -:CopyPEFiles -rem call copype.cmd amd64 "%cd%\wd" - -:Mount -rem echo Press any key to configure the WinPE image... -rem pause>nul -mkdir "%cd%\mount" -dism /mount-image /imagefile:"%cd%\wd\media\sources\boot.wim" /index:1 /mountdir:"%cd%\mount" - -:AddPackages -rem :: More info: https://msdn.microsoft.com/en-us/library/windows/hardware/dn938382(v=vs.85).aspx -rem dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\WinPE-FMAPI.cab" -rem dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\WinPE-WMI.cab" -rem dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\en-us\WinPE-WMI_en-us.cab" - -rem :: Install WinPE-WMI before you install WinPE-NetFX. -rem dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\WinPE-NetFx.cab" -rem dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\en-us\WinPE-NetFx_en-us.cab" -rem dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\WinPE-Scripting.cab" -rem dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\en-us\WinPE-Scripting_en-us.cab" - -rem :: Install WinPE-WMI > WinPE-NetFX > WinPE-Scripting before you install WinPE-PowerShell. -rem dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\WinPE-PowerShell.cab" -rem dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\en-us\WinPE-PowerShell_en-us.cab" - -rem :: Install WinPE-WMI > WinPE-NetFX > WinPE-Scripting > WinPE-PowerShell before you install WinPE-DismCmdlets. -rem dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\WinPE-DismCmdlets.cab" -rem dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\en-us\WinPE-DismCmdlets_en-us.cab" - -rem :: Install WinPE-WMI > WinPE-NetFX > WinPE-Scripting > WinPE-PowerShell before you install WinPE-SecureBootCmdlets. -rem dism /add-package /image:"%cd%\mount" /packagepath:"%winpe_ocs%\WinPE-SecureBootCmdlets.cab" - -:Robocopy -del "%cd%\WK\Scripts\WK.log" -rem mkdir "%cd%\mount\WK" -robocopy /e "%cd%\WK" "%cd%\mount\WK" - -:MenuLauncher -copy /y "%cd%\System32\menu.cmd" "%cd%\mount\Windows\System32\menu.cmd" - -:ReplaceStartnet -copy /y "%cd%\System32\startnet.cmd" "%cd%\mount\Windows\System32\startnet.cmd" - -:ReplaceNotepad -reg load HKLM\WinPE-SW mount\Windows\System32\config\SOFTWARE -reg add "HKLM\WinPE-SW\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v Debugger /t REG_SZ /d "X:\WK\Notepad2.exe /z" /f -reg add "HKLM\WinPE-SW\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\explorer.exe" /v Debugger /t REG_SZ /d "X:\WK\Explorer++.exe /z" /f -reg unload HKLM\WinPE-SW - -:Background -takeown /f "%cd%\mount\Windows\System32\winpe.jpg" /a -icacls "%cd%\mount\Windows\System32\winpe.jpg" /grant administrators:F -copy /y "%cd%\System32\winpe.jpg" "%cd%\mount\Windows\System32\winpe.jpg" - -:ManualStuff -echo Now is the time to add stuff (optional). -echo. -echo Press any key to commit changes... -pause>nul - -:Unmount -dism /unmount-image /mountdir:"%cd%\mount" /commit - -:CreateISO -del winpe10-test.iso -makewinpemedia.cmd /iso wd winpe10-test.iso -goto Done - -:Abort -echo. -echo Aborted. -goto Exit - -:Done -echo. -echo Done. -goto Exit - -:Exit -echo. -echo Press any key to exit... -pause>nul -popd -color -endlocal \ No newline at end of file