2015-11: Retroactive initial commit

This commit is contained in:
Alan Mason 2017-11-24 20:47:02 -08:00
commit 18c2c4a961
12 changed files with 1067 additions and 0 deletions

7
LICENSE.txt Normal file
View file

@ -0,0 +1,7 @@
Copyright (c) 2015 Alan Mason
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

18
README.md Normal file
View file

@ -0,0 +1,18 @@
# Wizard Kit PE #
A collection of scripts to help technicians service Windows systems.
# NOTICE: Currently under maintenance #
*These scripts are being reviewed and updated at the moment.*
Things may or may not work until this is completed. This warning will be removed once the maintenance is finished.
## Requirements ##
* Windows Assessment and Deployment Kit for Windows 10
## Initial Setup ##
* Install Windows ADK for Windows 10
* Run "Deployment and Imaging Tools Environment" as admin
* Run `make.cmd` to build a new Windows 10 PE image

34
System32/menu.cmd Normal file
View file

@ -0,0 +1,34 @@
@echo off
:Init
setlocal EnableDelayedExpansion
title Menu Launcher
color 0a
pushd %~dp0
:Flags
for %%f in (%*) do (
if /i "%%f" == "/DEBUG" (@echo on)
)
:LaunchMenu
PowerShell -ExecutionPolicy Bypass %systemdrive%\WK\Scripts\WK.ps1
goto Done
:Abort
echo.
echo Aborted.
goto Exit
:Done
echo.
echo Done.
goto Exit
:Exit
echo.
rem echo Press any key to exit...
rem pause>nul
popd
color
endlocal

10
System32/startnet.cmd Normal file
View file

@ -0,0 +1,10 @@
@echo off
echo Initializing...
wpeinit
wpeutil updatebootinfo
pushd %systemdrive%\WK
set "PATH=%PATH%;%systemdrive%\WK"
powershell -executionpolicy bypass -file %systemdrive%\WK\Scripts\WK.ps1

165
WK/FastCopy.ini Normal file
View file

@ -0,0 +1,165 @@
[main]
bufsize="128"
max_transize="16"
nonbuf_minsize_ntfs2="64"
nonbuf_minsize_fat="128"
is_readosbuf="0"
max_history="10"
default_copy_mode="1"
skip_empty_dir="1"
ignore_error="1"
estimate_mode="0"
disk_mode="0"
is_toplevel="0"
is_errlog="1"
is_utf8log="1"
filelog_mode="0"
aclerr_log="0"
streamerr_log="0"
is_samedir_rename="1"
shext_autoclose="1"
shext_tasktray="0"
shext_dd_noconfirm="0"
shext_right_noconfirm="0"
exec_confirm="0"
force_start="0"
lcid="-1"
speed_level="11"
overwrite_del="0"
acl="0"
stream="0"
verify="0"
nsa_del="0"
deldir_with_filter="0"
move_attr="0"
serial_move="0"
serial_verify_move="0"
reparse2="1"
extend_filter="0"
taskbarMode="0"
infoSpan="2"
win_pos="-10000,-10000,-10000,-10000"
driveMap=""
[src_history]
0=""
1=""
2=""
3=""
4=""
5=""
6=""
7=""
8=""
9=""
[dst_history]
0=""
1=""
2=""
3=""
4=""
5=""
6=""
7=""
8=""
9=""
[del_history]
0=""
1=""
2=""
3=""
4=""
5=""
6=""
7=""
8=""
9=""
[include_history]
0=""
1=""
2=""
3=""
4=""
5=""
6=""
7=""
8=""
9=""
[exclude_history]
0=""
1=""
2=""
3=""
4=""
5=""
6=""
7=""
8=""
9=""
[fromdate_history]
0=""
1=""
2=""
3=""
4=""
5=""
6=""
7=""
8=""
9=""
[todate_history]
0=""
1=""
2=""
3=""
4=""
5=""
6=""
7=""
8=""
9=""
[minsize_history]
0=""
1=""
2=""
3=""
4=""
5=""
6=""
7=""
8=""
9=""
[maxsize_history]
0=""
1=""
2=""
3=""
4=""
5=""
6=""
7=""
8=""
9=""
[finaction_0]
title="Normal"
sound=""
cmd=""
shutdown_time="-1"
flags="1"
[finaction_1]
title="Standby"
sound=""
cmd=""
shutdown_time="60"
flags="65"
[finaction_2]
title="Hibernate"
sound=""
cmd=""
shutdown_time="60"
flags="129"
[finaction_3]
title="Shutdown"
sound=""
cmd=""
shutdown_time="60"
flags="257"

131
WK/Notepad2.ini Normal file
View file

@ -0,0 +1,131 @@
[Settings]
SaveSettings=1
SaveRecentFiles=1
SaveFindReplace=1
CloseFind=0
CloseReplace=0
NoFindWrap=0
OpenWithDir=%SystemDrive%\
Favorites=%SystemDrive%\
PathNameFormat=1
WordWrap=0
WordWrapMode=0
WordWrapIndent=0
WordWrapSymbols=22
ShowWordWrapSymbols=0
MatchBraces=1
AutoCloseTags=0
HighlightCurrentLine=1
AutoIndent=1
AutoCompleteWords=0
ShowIndentGuides=0
TabsAsSpaces=1
TabIndents=1
BackspaceUnindents=0
TabWidth=4
IndentWidth=0
MarkLongLines=1
LongLinesLimit=80
LongLineMode=1
ShowSelectionMargin=0
ShowLineNumbers=1
ShowCodeFolding=1
MarkOccurrences=2
MarkOccurrencesMatchCase=0
MarkOccurrencesMatchWholeWords=0
ViewWhiteSpace=0
ViewEOLs=0
DefaultEncoding=3
SkipUnicodeDetection=0
LoadASCIIasUTF8=0
LoadNFOasOEM=1
NoEncodingTags=0
DefaultEOLMode=0
FixLineEndings=0
FixTrailingBlanks=0
PrintHeader=1
PrintFooter=0
PrintColorMode=3
PrintZoom=10
PrintMarginLeft=1000
PrintMarginTop=1000
PrintMarginRight=1000
PrintMarginBottom=1000
SaveBeforeRunningTools=1
FileWatchingMode=1
ResetFileWatching=0
EscFunction=2
AlwaysOnTop=0
MinimizeToTray=0
TransparentMode=0
ToolbarButtons=1 2 4 0 5 6 0 7 8 9 0 10 11 0 12 0 24 0 13 14 0 15 0 17
ShowToolbar=1
ShowStatusbar=1
EncodingDlgSizeX=256
EncodingDlgSizeY=262
RecodeDlgSizeX=256
RecodeDlgSizeY=262
FileMRUDlgSizeX=412
FileMRUDlgSizeY=376
OpenWithDlgSizeX=384
OpenWithDlgSizeY=386
FavoritesDlgSizeX=334
FavoritesDlgSizeY=316
FindReplaceDlgPosX=0
FindReplaceDlgPosY=0
[Settings2]
SingleFileInstance=1
ShellAppUserModelID=Notepad2
ShellUseSystemMRU=1
[Custom Colors]
01=#000000
02=#0A246A
03=#3A6EA5
04=#003CE6
05=#006633
06=#608020
07=#648000
08=#A46000
09=#FFFFFF
10=#FFFFE2
11=#FFF1A8
12=#FFC000
13=#FF4000
14=#C80000
15=#B000B0
16=#B28B40
[Styles]
Use2ndDefaultStyle=1
DefaultScheme=0
AutoSelect=1
SelectDlgSizeX=304
SelectDlgSizeY=324
[Default Text]
2nd Default Style=font:Lucida Console; size:10; fore:#C0C0C0; back:#000000
2nd Margins and Line Numbers=font:Tahoma; size:-3; fore:#808080; back:#000000
2nd Matching Braces=bold; fore:#00FF00
2nd Matching Braces Error=bold; fore:#FF0000
2nd Control Characters (Font)=size:-1
2nd Indentation Guide (Color)=fore:#808080
2nd Selected Text (Colors)=fore:#008000; back:#404040; alpha:50; eolfilled
2nd Whitespace (Colors, Size 0-5)=fore:#FF0000
2nd Current Line Background (Color)=back:#808080; alpha:50
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

413
WK/Scripts/WK.ps1 Normal file
View file

@ -0,0 +1,413 @@
# WK-Checklist
## Init ##
$wd = $(Split-Path $MyInvocation.MyCommand.Path)
pushd "$wd"
. .\init.ps1
clear
$host.UI.RawUI.WindowTitle = "WK PE Tool"
$logpath = "$WKPath\Info\$date"
md "$logpath" 2>&1 | out-null
$log = "$logpath\winpe.log"
$source_server = "10.0.0.10"
$backup_servers = @(
@{ "ip"="10.0.0.10";
"letter"="Z";
"name"="ServerOne";
"path"="Backups"},
@{ "ip"="10.0.0.11";
"name"="ServerTwo";
"letter"="Y";
"path"="Backups"}
)
$backup_user = "WORKGROUP\backup"
$backup_pass = "Abracadabra"
# Functions
function apply-image {
param([string]$image, [int]$index)
$path = ""
$split_image = $false
$split_image_pattern = ""
# Check for local source
$volumes = get-volume | where {$_.Size -ne 0 -and $_.DriveLetter -match '^[C-Z]$'}
foreach ($v in $volumes) {
$letter = $v.DriveLetter + ":"
if (test-path "$letter\sources\$image.wim") {
$path = "$letter\sources\$image.wim"
} elseif (test-path "$letter\sources\$image.swm") {
$path = "$letter\sources\$image.swm"
$split_image = $true
$split_image_pattern = "$letter\sources\$image*.swm"
}
}
# Check for remote source (if necessary)
if ($path -match '^$') {
net use z: "\\$source_server\Windows" /user:guest notarealpassword
if (test-path "Z:\$image.wim") {
$path = "Z:\$image.wim"
} elseif (test-path "Z:\$image.swm") {
$path = "Z:\$image.swm"
}
}
# Expand Image
if ($path -match '\.wim$') {
Expand-WindowsImage -ImagePath "$path" -Index $index -ApplyPath 'W:\'
} elseif ($path -match '\.swm$') {
Expand-WindowsImage -ImagePath "$path" -Index $index -ApplyPath 'W:\' -SplitImageFilePattern "$split_image_pattern"
} else {
net use z: /delete
throw "Source image not found."
}
net use z: /delete
}
function format-gpt {
param($dest_disk)
wk-write "Drive will use a GPT (UEFI) layout."
# Double-check we have the right drive
## I don't trust the order will be the same for diskpart & PS Storage Cmdlets
$_sel_uid = $dest_disk.Guid
if ($dest_disk.PartitionStyle -imatch "MBR") {
# MBR disks don't have GUIDs and use the signature in hex instead
$_sel_uid = "{0:x}" -f $dest_disk.Signature
}
$diskpart_script = "select disk {0}`r`n" -f $dest_disk.DiskNumber
$diskpart_script += "uniqueid disk"
out-file -encoding 'UTF8' -filepath "$wd\diskpart.script" -inputobject $diskpart_script
start "diskpart" -argumentlist @("/s", "$wd\diskpart.script") -wait -nonewwindow -PassThru -RedirectStandardOutput "$wd\drive_uid" | out-null
if (!(Get-Content "$wd\drive_uid" | where {$_ -imatch $_sel_uid})) {
# GUIDs do not match
wk-error "Diskpart failed to select the same disk for formatting, aborting setup."
wk-warn "This system requires manual formatting & setup"
wk-write ""
throw "Failed to format disk"
} else {
wk-write ("Selecting Disk {0} ({1})" -f $dest_disk.DiskNumber, $_sel_uid)
}
# Generate Diskpart script and execute
## NOTE 1: PS Storage Cmdlets can't be used; See Keith Garner's response here:
## https://social.technet.microsoft.com/Forums/en-US/9d78da31-557f-4408-89e0-a1603f7ebe0d
##
## NOTE 2: This overwrites existing diskpart.script file without confirmation.
$diskpart_script = "select disk {0}`r`n" -f $dest_disk.DiskNumber
$diskpart_script += "clean`r`n"
$diskpart_script += "convert gpt`r`n"
# 1. Windows RE tools partition (Windows 8+)
if ($dest_windows_version.Name -match '^Windows (8|10)') {
$diskpart_script += "create partition primary size=300`r`n"
$diskpart_script += "format quick fs=ntfs label='Windows RE tools'`r`n"
$diskpart_script += "assign letter='T'`r`n"
$diskpart_script += "set id='de94bba4-06d1-4d40-a16a-bfd50179d6ac'`r`n"
$diskpart_script += "gpt attributes=0x8000000000000001`r`n"
}
# 2. System partition
$diskpart_script += "create partition efi size=260`r`n"
## NOTE: Allows for Advanced Format 4Kn drives
$diskpart_script += "format quick fs=fat32 label='System'`r`n"
$diskpart_script += "assign letter='S'`r`n"
# 3. Microsoft Reserved (MSR) partition
$diskpart_script += "create partition msr size=128`r`n"
# 4. Windows partition
$diskpart_script += "create partition primary`r`n"
$diskpart_script += "format quick fs=ntfs label='Windows'`r`n"
$diskpart_script += "assign letter='W'`r`n"
# Run script
out-file -encoding 'UTF8' -filepath "$wd\diskpart.script" -inputobject $diskpart_script
start "diskpart" -argumentlist @("/s", "$wd\diskpart.script") -wait -nonewwindow
}
function format-mbr {
param($dest_disk)
wk-write "Drive will use a MBR (legacy) layout."
if ($dest_disk.PartitionStyle -notmatch '^RAW$') {
# Only clean if necessary
clear-Disk $dest_disk.DiskNumber -RemoveData -RemoveOEM -Confirm:$false
}
Initialize-Disk $dest_disk.DiskNumber -PartitionStyle 'MBR'
New-Partition -DiskNumber $dest_disk.DiskNumber -Size 100Mb -DriveLetter 'S' -IsActive:$true
New-Partition -DiskNumber $dest_disk.DiskNumber -UseMaximumSize -DriveLetter 'W' -IsActive:$false
Format-Volume -DriveLetter 'S' -FileSystem 'NTFS' -NewFileSystemLabel 'System Reserved'
Format-Volume -DriveLetter 'W' -FileSystem 'NTFS' -NewFileSystemLabel 'Windows'
}
function wk-exit {
popd
if ($answer -match 'R') {
#pause "Press Enter to Reboot... "
wpeutil reboot
} elseif ($answer -match 'S') {
#pause "Press Enter to Shutdown... "
wpeutil shutdown
}
exit 0
}
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) {
try {
$_path = "\\{0}\{1}" -f $_server.ip, $_server.path
$_drive = "{0}:" -f $_server.letter
net use $_drive "$_path" /user:$backup_user $backup_pass | out-null
wk-write ("`t{0} server: mounted" -f $_server.name)
# Add friendly description
$_regex = "^{0}$" -f $_server.letter
(gdr | where {$_.Name -imatch $_regex}).Description = $_server.name
} catch {
wk-warn ("`t{0} server: failed" -f $_server.name)
}
} else {
wk-warn ("`t{0} server: unreachable" -f $_server.name)
}
}
}
function unmount-servers {
# Unmount servers
wk-write "Disconnecting from backup server(s)"
$mounted_servers = @(gdr | where {$_.DisplayRoot -imatch '\\\\'})
foreach ($_server in $mounted_servers) {
try {
$_drive = "{0}:" -f $_server.Name
net use $_drive /delete | out-null
wk-warn ("`t{0} server: unmounted" -f $_server.name)
} catch {
wk-warn ("`t{0} server: failed" -f $_server.name)
}
}
}
function menu-imaging {
wk-write "Drive Imaging"
wk-write ""
## WARNING
wk-warn "WARNING: This section is experimental"
pause
## WARNING
# Mount server(s)
mount-servers
# Select destination
$avail_servers = @(gdr | where {$_.DisplayRoot -imatch '\\\\'})
$menu_disc_imaging = "Which drive are we imaging?`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_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"
do {
clear
$answer = read-host -prompt $menu_disc_imaging
} 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]
}
# Service Order
$menu_service_order += "Please enter the service order`r`n"
do {
clear
$service_order = read-host -prompt $menu_service_order
} until ($service_order -imatch '^\d[\w\-]+$')
# Backup partitions
wk-write ("Saving partition backups to: {0}" -f $dest_backup_server.Description)
wk-write ("`t{0}{1}" -f $dest_backup_server.Root, $service_order)
# Unmount server(s)
unmount-servers
pause "Press Enter to return to main menu... "
}
function menu-setup {
wk-write "Windows Setup"
wk-write ""
pushd $WKPath\Setup
# Build windows menu
$windows_versions = @(
@{Name="Windows 7 Home Premium"; ImageFile="Win7"; Index=1},
@{Name="Windows 7 Professional"; ImageFile="Win7"; Index=2},
@{Name="Windows 7 Ultimate"; ImageFile="Win7"; Index=3},
@{Name="Windows 8.1"; ImageFile="Win8"; Index=1},
@{Name="Windows 8.1 Pro"; ImageFile="Win8"; Index=2},
@{Name="Windows 10 Home"; ImageFile="Win10"; Index=1},
@{Name="Windows 10 Pro"; ImageFile="Win10"; Index=2}
)
$menu_setup_windows = "Which version of Windows are we installing?`r`n`r`n"
$valid_answers = @("M", "m")
for ($i=0; $i -lt $windows_versions.length; $i++) {
$valid_answers += ($i + 1)
$menu_setup_windows += "{0}: {1}`r`n" -f ($i + 1), $windows_versions[$i].Name
}
$menu_setup_windows += "`r`n"
$menu_setup_windows += "M: Main Menu`r`n"
$menu_setup_windows += "`r`n"
$menu_setup_windows += "Please make a selection`r`n"
# Select Windows version
do {
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
$dest_windows_version = $windows_versions[$answer]
}
# 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
}
$menu_setup_disk += "`r`n"
$menu_setup_disk += "M: Main Menu`r`n"
$menu_setup_disk += "`r`n"
$menu_setup_disk += "Please make a selection`r`n"
# Select disk
do {
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
$dest_disk = $disks | where {$_.DiskNumber -eq $answer}
wk-warn "All data will be deleted from the following drive:"
wk-warn ("`t{0:N0} Gb`t({1}) {2}`r`n" -f ($dest_disk.Size / 1GB), $dest_disk.PartitionStyle, $dest_disk.FriendlyName)
if (ask ("Proceed and install {0}?" -f $dest_windows_version.Name)) {
wk-warn "SAFTEY CHECK:"
wk-write (" Installing:`t{0}" -f $dest_windows_version.Name)
wk-error (" And ERASING:`tDisk {0} - {1:N0} Gb`t({2}) {3}`r`n" -f $dest_disk.DiskNumber, ($dest_disk.Size / 1GB), $dest_disk.PartitionStyle, $dest_disk.FriendlyName)
if (ask "Is this correct?") {
## WARNING
wk-warn "WARNING: This section is experimental"
## WARNING
## Here be dragons
try {
# Select UEFI or BIOS
if ($dest_windows_version.Name -match '^Windows 7') {
if (ask "Setup drive using MBR (legacy) layout?") {
format-mbr $dest_disk
} else {
format-gpt $dest_disk
}
} elseif ($dest_windows_version.Name -match '^Windows (8|10)') {
if (ask "Setup drive using GPT (UEFI) layout?") {
format-gpt $dest_disk
} else {
format-mbr $dest_disk
}
}
# Apply image
apply-image $dest_windows_version.ImageFile $dest_windows_version.Index
# Create boot files (copies files for both Legacy and UEFI)
bcdboot W:\Windows /s S: /f ALL
if ($dest_windows_version.Name -match '^Windows (8|10)') {
W:\Windows\System32\reagentc /setreimage /path T:\Recovery\WindowsRE /target W:\Windows
}
# Reboot
wk-write "Windows Setup complete."
wk-write ""
return 0
} catch {
wk-error "$Error"
wk-error "Windows Setup aborted."
wk-write ""
pause "Press Enter to return to main menu... "
return 1
}
} else {
wk-error "Windows Setup aborted."
wk-write ""
pause "Press Enter to return to main menu... "
}
} else {
wk-error "Windows Setup aborted."
wk-write ""
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")
wk-exit
}
function menu-main {
$answered = $false
$menu_main = @"
WK WinPE Tools
1: Drive Imaging
2: Windows Setup
3: Misc Tools
Q: Quit
R: Reboot
S: Shutdown
Please make a selection
"@
do {
clear
$answer = read-host -prompt $menu_main
} until ($answer -imatch '^[123QRS]$')
clear
if ($answer.GetType().Name -match "String") {
$answer = $answer.ToUpper()
}
switch ($answer) {
1 {menu-imaging; break}
2 {menu-setup; break}
3 {menu-tools; break}
default {wk-exit}
}
}
# Main Loop
do {
menu-main
} while ($true)

48
WK/Scripts/init.ps1 Normal file
View file

@ -0,0 +1,48 @@
# WK-Init
#
# Some common settings and functions
$host.UI.RawUI.BackgroundColor = "black"
$host.UI.RawUI.ForegroundColor = "green"
$systemdrive = (gci env:systemdrive).value
$WKPath = "$systemdrive\WK"
$date = get-date -uformat "%Y-%m-%d"
function ask {
param([string]$text = "Kotaero", [string]$log = "WK.log")
$answered = $false
$text += " [Y/N]"
while (!$answered) {
$answer = read-host $text
if ($answer -imatch '^(y|yes)$') {
$answer = $true
$answered = $true
} elseif ($answer -imatch '^(n|no)$') {
$answer = $false
$answered = $true
}
}
$text += ": $answer"
out-file -filepath $log -inputobject $text -append
return $answer
}
function wk-error {
param([string]$text = "ERROR", [string]$log = "WK.log")
write-host ($text) -foreground "red"
out-file -filepath $log -inputobject $text -append
}
function wk-warn {
param([string]$text = "WARNING", [string]$log = "WK.log")
write-host ($text) -foreground "yellow"
out-file -filepath $log -inputobject $text -append
}
function wk-write {
param([string]$text = "<TODO>", [string]$log = "WK.log")
write-host ($text)
out-file -filepath $log -inputobject $text -append
}
function pause {
param([string]$message = "Press Enter to continue... ")
write-host $message
$x = read-host
}

7
WK/hwmonitorw.ini Normal file
View file

@ -0,0 +1,7 @@
[HWMonitor]
VERSION=1.2.8.0
USE_ACPI=1
USE_SMBUS=1
USE_SMART=1
USE_DISPLAY=1
UPDATES=0

34
make-cd.cmd Normal file
View file

@ -0,0 +1,34 @@
@echo off
:Init
setlocal EnableDelayedExpansion
title WinPE 10 creation tool
color 1b
pushd %~dp0
:Flags
for %%f in (%*) do (
if /i "%%f" == "/DEBUG" (@echo on)
)
:CreateISO
del winpe10-test.iso
makewinpemedia.cmd /iso wd winpe10-test.iso
: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

100
make.cmd Normal file
View file

@ -0,0 +1,100 @@
@echo off
:Init
setlocal EnableDelayedExpansion
title WinPE 10 creation 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
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
:: 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"
:: 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"
:: 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"
:: 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"
:: 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"
:Robocopy
del "%cd%\WK\Scripts\WK.log"
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

100
update.cmd Normal file
View file

@ -0,0 +1,100 @@
@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