2016-09: Retroactive Updates
* Added WIM backup image verification phase * WIM backup images now created much faster * This was done by not creating the extra integrity information * Readded support for swm files * ComEmu will now open in fullscreen mode without the titlebar
This commit is contained in:
parent
29c1870957
commit
8cf135d9eb
4 changed files with 102 additions and 44 deletions
|
|
@ -150,13 +150,13 @@ def assign_volume_letters():
|
|||
except:
|
||||
pass
|
||||
|
||||
def remove_volume_letters():
|
||||
def remove_volume_letters(keep=None):
|
||||
with open(diskpart_script, 'w') as script:
|
||||
script.write('list volume\n')
|
||||
process_return = run_program('diskpart /s {script}'.format(script=diskpart_script))
|
||||
with open(diskpart_script, 'w') as script:
|
||||
for tmp in re.findall(r'Volume (\d+)\s+([A-Za-z]?)\s+', process_return.stdout.decode()):
|
||||
if tmp[1] != '':
|
||||
if tmp[1] != '' and tmp[1] != keep:
|
||||
script.write('select volume {number}\n'.format(number=tmp[0]))
|
||||
script.write('remove\n')
|
||||
try:
|
||||
|
|
@ -192,7 +192,7 @@ def select_minidump_path():
|
|||
|
||||
def find_windows_image(filename=None):
|
||||
"""Search for a Windows source image file on local drives and network drives (in that order)"""
|
||||
image_file = None
|
||||
image = {}
|
||||
|
||||
# Bail early
|
||||
if filename is None:
|
||||
|
|
@ -203,19 +203,30 @@ def find_windows_image(filename=None):
|
|||
for tmp in re.findall(r'.*([A-Za-z]):\\', process_return.stdout.decode()):
|
||||
for ext in ['esd', 'wim', 'swm']:
|
||||
if os.path.isfile('{drive}:\\images\\{filename}.{ext}'.format(drive=tmp[0], ext=ext, filename=filename)):
|
||||
image_file = '{drive}:\\images\\{filename}.{ext}'.format(drive=tmp[0], ext=ext, filename=filename)
|
||||
image['Ext'] = ext
|
||||
image['File'] = '{drive}:\\images\\{filename}'.format(drive=tmp[0], filename=filename)
|
||||
image['Glob'] = '--ref="{File}*.swm"'.format(**image) if ext == 'swm' else ''
|
||||
image['Source'] = tmp[0]
|
||||
break
|
||||
|
||||
# Check for network source (if necessary)
|
||||
if image_file is None:
|
||||
if not any(image):
|
||||
if not WINDOWS_SERVER['Mounted']:
|
||||
mount_windows_share()
|
||||
for ext in ['esd', 'wim']:
|
||||
for ext in ['esd', 'wim', 'swm']:
|
||||
if os.path.isfile('\\\\{IP}\\{Share}\\images\\{filename}.{ext}'.format(ext=ext, filename=filename, **WINDOWS_SERVER)):
|
||||
image_file = '\\\\{IP}\\{Share}\\images\\{filename}.{ext}'.format(ext=ext, filename=filename, **WINDOWS_SERVER)
|
||||
image['Ext'] = ext
|
||||
image['File'] = '\\\\{IP}\\{Share}\\images\\{filename}'.format(filename=filename, **WINDOWS_SERVER)
|
||||
image['Glob'] = '--ref="{File}*.swm"'.format(**image) if ext == 'swm' else ''
|
||||
image['Source'] = None
|
||||
break
|
||||
|
||||
return image_file
|
||||
|
||||
# Display image to be used (if any) and return
|
||||
if any(image):
|
||||
print_info('Using image: {File}.{Ext}'.format(**image))
|
||||
return image
|
||||
else:
|
||||
return None
|
||||
|
||||
def format_gpt(disk=None, windows_family=None):
|
||||
"""Format disk for use as a Windows OS drive using the GPT (UEFI) layout."""
|
||||
|
|
@ -431,16 +442,42 @@ def select_disk(prompt='Which disk?'):
|
|||
|
||||
def select_windows_version():
|
||||
versions = [
|
||||
{'Name': 'Windows 7 Home Basic', 'ImageFile': 'Win7', 'ImageName': 'Windows 7 HOMEBASIC', 'Family': '7'},
|
||||
{'Name': 'Windows 7 Home Premium', 'ImageFile': 'Win7', 'ImageName': 'Windows 7 HOMEPREMIUM', 'Family': '7'},
|
||||
{'Name': 'Windows 7 Professional', 'ImageFile': 'Win7', 'ImageName': 'Windows 7 PROFESSIONAL', 'Family': '7'},
|
||||
{'Name': 'Windows 7 Ultimate', 'ImageFile': 'Win7', 'ImageName': 'Windows 7 ULTIMATE', 'Family': '7'},
|
||||
{'Name': 'Windows 7 Home Basic',
|
||||
'ImageFile': 'Win7',
|
||||
'ImageName': 'Windows 7 HOMEBASIC',
|
||||
'Family': '7'},
|
||||
{'Name': 'Windows 7 Home Premium',
|
||||
'ImageFile': 'Win7',
|
||||
'ImageName': 'Windows 7 HOMEPREMIUM',
|
||||
'Family': '7'},
|
||||
{'Name': 'Windows 7 Professional',
|
||||
'ImageFile': 'Win7',
|
||||
'ImageName': 'Windows 7 PROFESSIONAL',
|
||||
'Family': '7'},
|
||||
{'Name': 'Windows 7 Ultimate',
|
||||
'ImageFile': 'Win7',
|
||||
'ImageName': 'Windows 7 ULTIMATE',
|
||||
'Family': '7'},
|
||||
|
||||
{'Name': 'Windows 8.1', 'ImageFile': 'Win8', 'ImageName': 'Windows 8.1', 'Family': '8', 'CRLF': True},
|
||||
{'Name': 'Windows 8.1 Pro', 'ImageFile': 'Win8', 'ImageName': 'Windows 8.1 Pro', 'Family': '8'},
|
||||
{'Name': 'Windows 8.1',
|
||||
'ImageFile': 'Win8',
|
||||
'ImageName': 'Windows 8.1',
|
||||
'Family': '8',
|
||||
'CRLF': True},
|
||||
{'Name': 'Windows 8.1 Pro',
|
||||
'ImageFile': 'Win8',
|
||||
'ImageName': 'Windows 8.1 Pro',
|
||||
'Family': '8'},
|
||||
|
||||
{'Name': 'Windows 10 Home', 'ImageFile': 'Win10', 'ImageName': 'Windows 10 Home', 'Family': '10', 'CRLF': True},
|
||||
{'Name': 'Windows 10 Pro', 'ImageFile': 'Win10', 'ImageName': 'Windows 10 Pro', 'Family': '10'},
|
||||
{'Name': 'Windows 10 Home',
|
||||
'ImageFile': 'Win10',
|
||||
'ImageName': 'Windows 10 Home',
|
||||
'Family': '10',
|
||||
'CRLF': True},
|
||||
{'Name': 'Windows 10 Pro',
|
||||
'ImageFile': 'Win10',
|
||||
'ImageName': 'Windows 10 Pro',
|
||||
'Family': '10'},
|
||||
]
|
||||
actions = [
|
||||
{'Name': 'Main Menu', 'Letter': 'M'},
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ def menu_backup_imaging():
|
|||
|
||||
# List (and update) partition details for selected drive
|
||||
os.system('cls')
|
||||
print('Details for selected drive:\n')
|
||||
print('Create Backup - Details:\n')
|
||||
print(' Drive: {Size}\t[{Table}] ({Type}) {Name}\n'.format(**disk))
|
||||
clobber_risk = 0
|
||||
width=len(str(len(disk['Partitions'])))
|
||||
|
|
@ -84,7 +84,8 @@ def menu_backup_imaging():
|
|||
par['ImagePath'] = '\\\\{IP}\\{Share}\\{ticket}'.format(ticket=ticket, **dest)
|
||||
else:
|
||||
par['ImagePath'] = '{Letter}:\\{ticket}'.format(ticket=ticket, **dest)
|
||||
par['ImageFile'] = '{Number}_{ImageName}.wim'.format(**par)
|
||||
par['ImageFile'] = '{Number}_{ImageName}'.format(**par)
|
||||
par['ImageFile'] = '{fixed_name}.wim'.format(fixed_name=re.sub(r'\W', '_', par['ImageFile']))
|
||||
|
||||
# Check for existing backups
|
||||
par['ImageExists'] = False
|
||||
|
|
@ -108,9 +109,9 @@ def menu_backup_imaging():
|
|||
elif len(bad_parts) == 1:
|
||||
print_warning(' * Unable to backup this partition')
|
||||
if clobber_risk > 1:
|
||||
print_info(' + These partitions already have backup images on {TrueName}:'.format(**dest))
|
||||
print_info(' + These partitions already have backup images on {Display Name}:'.format(**dest))
|
||||
elif clobber_risk == 1:
|
||||
print_info(' + This partition already has a backup image on {TrueName}:'.format(**dest))
|
||||
print_info(' + This partition already has a backup image on {Display Name}:'.format(**dest))
|
||||
if clobber_risk + len(bad_parts) > 1:
|
||||
print_warning('\nIf you continue the partitions marked above will NOT be backed up.\n')
|
||||
if clobber_risk + len(bad_parts) == 1:
|
||||
|
|
@ -131,7 +132,7 @@ def menu_backup_imaging():
|
|||
if par['Number'] in bad_parts:
|
||||
print_warning('Skipped.')
|
||||
else:
|
||||
cmd = '{bin}\\wimlib\\wimlib-imagex capture {Letter}:\\ "{ImagePath}\\{ImageFile}" "{ImageName}" "{ImageName}" --check --compress=fast'.format(bin=bin, **par)
|
||||
cmd = '{bin}\\wimlib\\wimlib-imagex capture {Letter}:\\ "{ImagePath}\\{ImageFile}" "{ImageName}" "{ImageName}" --compress=fast'.format(bin=bin, **par)
|
||||
if par['ImageExists']:
|
||||
print_warning('Skipped.')
|
||||
else:
|
||||
|
|
@ -144,9 +145,29 @@ def menu_backup_imaging():
|
|||
errors = True
|
||||
par['Error'] = err.stderr.decode().splitlines()
|
||||
|
||||
# Verify backup(s)
|
||||
if len(par) - len(bad_parts) > 1:
|
||||
print('\n\n Verifying backups\n')
|
||||
else:
|
||||
print('\n\n Verifying backup\n')
|
||||
for par in disk['Partitions']:
|
||||
if par['Number'] not in bad_parts:
|
||||
print(' Partition {Number} Image...\t\t'.format(**par), end='', flush=True)
|
||||
cmd = '{bin}\\wimlib\\wimlib-imagex verify "{ImagePath}\\{ImageFile}" --nocheck'.format(bin=bin, **par)
|
||||
if not os.path.exists('{ImagePath}\\{ImageFile}'.format(**par)):
|
||||
print_error('Missing.')
|
||||
else:
|
||||
try:
|
||||
run_program(cmd)
|
||||
print_success('OK.')
|
||||
except subprocess.CalledProcessError as err:
|
||||
print_error('Damaged.')
|
||||
errors = True
|
||||
par['Error'] = par.get('Error', []) + err.stderr.decode().splitlines()
|
||||
|
||||
# Print summary
|
||||
if errors:
|
||||
print_warning('\nErrors were encountered during imaging and are detailed below.')
|
||||
print_warning('\nErrors were encountered and are detailed below.')
|
||||
for par in [p for p in disk['Partitions'] if 'Error' in p]:
|
||||
print(' Partition {Number} Error:'.format(**par))
|
||||
for line in par['Error']:
|
||||
|
|
@ -169,8 +190,8 @@ def menu_windows_setup():
|
|||
abort_to_main_menu('Aborting Windows setup')
|
||||
|
||||
# Find Windows image
|
||||
image_file = find_windows_image(selected_windows_version['ImageFile'])
|
||||
if image_file is None:
|
||||
image = find_windows_image(selected_windows_version['ImageFile'])
|
||||
if not any(image):
|
||||
print_error('Failed to find Windows source image for {winver}'.format(winver=selected_windows_version['Name']))
|
||||
abort_to_main_menu('Aborting Windows setup')
|
||||
|
||||
|
|
@ -221,7 +242,7 @@ def menu_windows_setup():
|
|||
abort_to_main_menu('Aborting Windows setup')
|
||||
|
||||
# Release currently used volume letters (ensures that the drives will get S, T, & W as needed below)
|
||||
remove_volume_letters()
|
||||
remove_volume_letters(keep=image['Source'])
|
||||
|
||||
# Format and partition drive
|
||||
if (use_gpt):
|
||||
|
|
@ -232,7 +253,7 @@ def menu_windows_setup():
|
|||
# Apply Windows image
|
||||
errors = False
|
||||
print(' Applying image...')
|
||||
cmd = '{bin}\\wimlib\\wimlib-imagex apply "{image_file}" "{ImageName}" W:\\'.format(bin=bin, image_file=image_file, **selected_windows_version)
|
||||
cmd = '{bin}\\wimlib\\wimlib-imagex apply "{File}.{Ext}" "{ImageName}" W:\\ {Glob}'.format(bin=bin, **image, **selected_windows_version)
|
||||
try:
|
||||
run_program(cmd)
|
||||
except subprocess.CalledProcessError:
|
||||
|
|
@ -251,8 +272,8 @@ def menu_windows_setup():
|
|||
try:
|
||||
run_program('W:\\Windows\\System32\\reagentc /setreimage /path T:\\Recovery\\WindowsRE /target W:\\Windows')
|
||||
except subprocess.CalledProcessError:
|
||||
errors = True
|
||||
print_error('Failed to setup WindowsRE files.')
|
||||
# errors = True # Changed to warning.
|
||||
print_warning('Failed to setup WindowsRE files.')
|
||||
|
||||
# Print summary
|
||||
if errors:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<key name="Software">
|
||||
<key name="ConEmu">
|
||||
<key name=".Vanilla" modified="2016-07-06 23:56:00" build="160619">
|
||||
<key name=".Vanilla" modified="2016-09-05 17:38:00" build="160619">
|
||||
<value name="ColorTable00" type="dword" data="00222827"/>
|
||||
<value name="ColorTable01" type="dword" data="009e5401"/>
|
||||
<value name="ColorTable02" type="dword" data="0004aa74"/>
|
||||
|
|
@ -112,7 +112,7 @@
|
|||
<value name="Monospace" type="hex" data="01"/>
|
||||
<value name="BackGround Image show" type="hex" data="01"/>
|
||||
<value name="BackGround Image" type="string" data="winpe.jpg"/>
|
||||
<value name="bgImageDarker" type="hex" data="30"/>
|
||||
<value name="bgImageDarker" type="hex" data="50"/>
|
||||
<value name="bgImageColors" type="dword" data="ffffffff"/>
|
||||
<value name="bgOperation" type="hex" data="07"/>
|
||||
<value name="bgPluginAllowed" type="hex" data="01"/>
|
||||
|
|
@ -123,7 +123,7 @@
|
|||
<value name="ColorKeyTransparent" type="hex" data="00"/>
|
||||
<value name="ColorKeyValue" type="dword" data="00010101"/>
|
||||
<value name="UseCurrentSizePos" type="hex" data="01"/>
|
||||
<value name="WindowMode" type="dword" data="0000051f"/>
|
||||
<value name="WindowMode" type="dword" data="00000520"/>
|
||||
<value name="ConWnd Width" type="dword" data="02000057"/>
|
||||
<value name="ConWnd Height" type="dword" data="02000057"/>
|
||||
<value name="Cascaded" type="hex" data="00"/>
|
||||
|
|
@ -134,10 +134,10 @@
|
|||
<value name="IntegralSize" type="hex" data="00"/>
|
||||
<value name="QuakeStyle" type="hex" data="00"/>
|
||||
<value name="QuakeAnimation" type="ulong" data="300"/>
|
||||
<value name="HideCaption" type="hex" data="00"/>
|
||||
<value name="HideCaption" type="hex" data="01"/>
|
||||
<value name="HideChildCaption" type="hex" data="01"/>
|
||||
<value name="FocusInChildWindows" type="hex" data="01"/>
|
||||
<value name="HideCaptionAlways" type="hex" data="00"/>
|
||||
<value name="HideCaptionAlways" type="hex" data="01"/>
|
||||
<value name="HideCaptionAlwaysFrame" type="hex" data="00"/>
|
||||
<value name="HideCaptionAlwaysDelay" type="ulong" data="2000"/>
|
||||
<value name="HideCaptionAlwaysDisappear" type="ulong" data="2000"/>
|
||||
|
|
@ -483,9 +483,9 @@
|
|||
<value name="DndLKey" type="hex" data="00"/>
|
||||
<value name="DndRKey" type="hex" data="a2"/>
|
||||
<value name="WndDragKey" type="dword" data="00121101"/>
|
||||
<key name="Tasks" modified="2016-07-06 23:56:00" build="160619">
|
||||
<key name="Tasks" modified="2016-09-05 17:38:00" build="160619">
|
||||
<value name="Count" type="long" data="3"/>
|
||||
<key name="Task1" modified="2016-07-06 23:56:00" build="160619">
|
||||
<key name="Task1" modified="2016-09-05 17:38:00" build="160619">
|
||||
<value name="Name" type="string" data="{cmd}"/>
|
||||
<value name="GuiArgs" type="string" data="/icon "%CMDER_ROOT%\cmder.exe""/>
|
||||
<value name="Cmd1" type="string" data="cmd /k "%ConEmuDir%\..\init.bat" -new_console:d:%USERPROFILE%"/>
|
||||
|
|
@ -494,7 +494,7 @@
|
|||
<value name="Hotkey" type="dword" data="00000000"/>
|
||||
<value name="Flags" type="dword" data="00000000"/>
|
||||
</key>
|
||||
<key name="Task2" modified="2016-07-06 23:56:00" build="160619">
|
||||
<key name="Task2" modified="2016-09-05 17:38:00" build="160619">
|
||||
<value name="Name" type="string" data="{PowerShell}"/>
|
||||
<value name="GuiArgs" type="string" data="/icon "%CMDER_ROOT%\cmder.exe""/>
|
||||
<value name="Cmd1" type="string" data="PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command "Invoke-Expression '. ''%ConEmuDir%\..\profile.ps1'''" -new_console:d:"%USERPROFILE%""/>
|
||||
|
|
@ -503,7 +503,7 @@
|
|||
<value name="Hotkey" type="dword" data="00000000"/>
|
||||
<value name="Flags" type="dword" data="00000000"/>
|
||||
</key>
|
||||
<key name="Task3" modified="2016-07-06 23:56:00" build="160619">
|
||||
<key name="Task3" modified="2016-09-05 17:38:00" build="160619">
|
||||
<value name="Name" type="string" data="{PowerShell as Admin}"/>
|
||||
<value name="Hotkey" type="dword" data="00000000"/>
|
||||
<value name="GuiArgs" type="string" data="/icon "%CMDER_ROOT%\cmder.exe""/>
|
||||
|
|
@ -512,7 +512,7 @@
|
|||
<value name="Count" type="long" data="1"/>
|
||||
<value name="Flags" type="dword" data="00000000"/>
|
||||
</key>
|
||||
<key name="Task4" modified="2015-02-24 18:49:50" build="140707">
|
||||
<key name="Task4" modified="2016-09-05 17:38:00" build="140707">
|
||||
<value name="Name" type="string" data="{git sh}"/>
|
||||
<value name="Hotkey" type="dword" data="00000000"/>
|
||||
<value name="GuiArgs" type="string" data=" /icon "%CMDER_ROOT%\cmder.exe""/>
|
||||
|
|
@ -523,11 +523,11 @@
|
|||
</key>
|
||||
</key>
|
||||
|
||||
<key name="Apps" modified="2016-07-06 23:56:00" build="160619">
|
||||
<key name="Apps" modified="2016-09-05 17:38:00" build="160619">
|
||||
<value name="Count" type="long" data="0"/>
|
||||
</key>
|
||||
<key name="Colors" modified="2016-07-06 23:56:00" build="160619">
|
||||
<key name="Palette1" modified="2016-07-06 23:56:00" build="160619">
|
||||
<key name="Colors" modified="2016-09-05 17:38:00" build="160619">
|
||||
<key name="Palette1" modified="2016-09-05 17:38:00" build="160619">
|
||||
<value name="Name" type="string" data="Monokai"/>
|
||||
<value name="ExtendColors" type="hex" data="00"/>
|
||||
<value name="ExtendColorIdx" type="hex" data="0e"/>
|
||||
|
|
@ -628,7 +628,7 @@
|
|||
<value name="StatusBar.Hide.Dpi" type="hex" data="01"/>
|
||||
<value name="TabFlashChanged" type="long" data="8"/>
|
||||
<value name="TabModifiedSuffix" type="string" data="[*]"/>
|
||||
<key name="HotKeys" modified="2016-07-06 23:56:00" build="160619">
|
||||
<key name="HotKeys" modified="2016-09-05 17:38:00" build="160619">
|
||||
<value name="KeyMacroVersion" type="hex" data="02"/>
|
||||
<value name="Multi.Modifier" type="dword" data="00000011"/>
|
||||
<value name="Multi.ArrowsModifier" type="dword" data="0000005b"/>
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@
|
|||
<value name="Monospace" type="hex" data="01"/>
|
||||
<value name="BackGround Image show" type="hex" data="01"/>
|
||||
<value name="BackGround Image" type="string" data="winpe.jpg"/>
|
||||
<value name="bgImageDarker" type="hex" data="30"/>
|
||||
<value name="bgImageDarker" type="hex" data="50"/>
|
||||
<value name="bgImageColors" type="dword" data="ffffffff"/>
|
||||
<value name="bgOperation" type="hex" data="07"/>
|
||||
<value name="bgPluginAllowed" type="hex" data="01"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue