Skip to content

Commit

Permalink
Version 3.1.1 (2024-11-15)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGeeraerts committed Nov 15, 2024
1 parent b5128c0 commit 11b3c81
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 35 deletions.
22 changes: 16 additions & 6 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@
[//]: # (#### Deprecated)

---

## Version 3.1.1 (2024-11-15)
#### Added
- Console output

#### Changed
- changed variable $APPX_LIST to $APPX_FILE
- default step# to main

#### Fixed
- $DEBUG variable

---


## Version 3.1.0 (2024-11-15)
#### Added
- sets the local user to first logged on user
Expand All @@ -27,12 +42,7 @@
#### Changed
- not KB list is now read from [file](config/Windows_Update_KB_List.txt)
- $CONFIG_SCHEMA_VERSION_MIN to 3.1.0
- - path to $APPX_LIST

#### Fixed

---

- path to $APPX_LIST

## Version 3.0.2 (2024-11-14)
#### Fixed
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ Download the project as .zip file from [releases](https://github.com/DavidGeerae

- APPX packages can be added back after image depployment.

- Troubleshoot this error: `SYSPRP Failed to remove apps for the current user: 0x80073cf2.`
- Open the setuperr.log and find which APPX package caused sysprep to fail.
- Add that package by name --not the full package name-- to the [APPX_List.txt](config/APPX_List.txt) file.


:five: Windows Update

Expand Down
1 change: 1 addition & 0 deletions config/APPX_List.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Microsoft.WidgetsPlatformRuntime
Microsoft.OneDriveSync
MicrosoftWindows.Client.WebExperience
Microsoft.BingNews
Microsoft.BingSearch
Microsoft.YourPhone
Microsoft.WindowsMaps
Microsoft.ZuneMusic
Expand Down
4 changes: 2 additions & 2 deletions config/module_system_SysPrep.properties
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $KEYWORD_SCHEDULED_TASK=OneDrive

# [DELETE] Microsoft APPX Packages
# File that contains a list of APPX packages to delete using keywords
$APPX_LIST=APPX_List.txt
$APPX_FILE=APPX_List.txt

# Windows Update via powershell, KB exclusion
# NotKBArticleFile with space between KB's
Expand Down Expand Up @@ -90,7 +90,7 @@ $TIMEOUT=5
#############################################################################

# Turn on [1] or off [0]
$DEGUB=0
$DEBUG=1

# Log Directory
$LD=logs
Expand Down
57 changes: 30 additions & 27 deletions module_system_SysPrep.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
@echo Off
SETLOCAL Enableextensions
SET $SCRIPT_NAME=module_system_SysPrep
SET $SCRIPT_VERSION=3.1.0
SET $SCRIPT_BUILD=20241115 0830
SET $SCRIPT_VERSION=3.1.1
SET $SCRIPT_BUILD=20241115 1030
Title %$SCRIPT_NAME% Version: %$SCRIPT_VERSION%
mode con:cols=70
mode con:lines=40
Expand All @@ -60,7 +60,7 @@ SET "$KEYWORD_SCHEDULED_TASK=OneDrive"
:: [DELETE] Microsoft APPX Packages
:: File that contains a list of APPX packages to delete using keywords
:: pathed to config
SET $APPX_List=APPX_List.txt
SET $APPX_FILE=APPX_List.txt

:: Windows Update via powershell, KB exclusion
:: NotKBArticleFile with space between KB's
Expand Down Expand Up @@ -98,7 +98,7 @@ SET $TIMEOUT=5
::###########################################################################::

:: Turn on [1] or off [0]
SET $DEGUB=0
SET $DEBUG=0

:: Default properties file name
SET $CONFIG_FILE=module_system_SysPrep.properties
Expand Down Expand Up @@ -248,12 +248,13 @@ REM FOR /F %%R IN ('ECHO %VARIABLE%') DO SET $VARIABLE=%%R

:: LOADING PROPERTIES
:: Debug
FOR /F "tokens=2 delims=^=" %%V IN ('FINDSTR /BC:"$DEGU" "%~dp0\config\%$CONFIG_FILE%"') DO SET "$DEGU=%%V"
echo $DEGU: %$DEGU%
FOR /F "tokens=2 delims=^=" %%V IN ('FINDSTR /BC:"$DEBUG" "%~dp0\config\%$CONFIG_FILE%"') DO SET "$DEBUG=%%V"
echo $DEBUG: %$DEBUG%
IF NOT DEFINED $DEBUG SET $DEBUG=1
:: APPX list file
FOR /F "tokens=2 delims=^=" %%V IN ('FINDSTR /BC:"$APPX_List" "%~dp0\config\%$CONFIG_FILE%"') DO SET "$APPX_List=%%V"
echo $APPX_List: %$APPX_List%
if exist "%~dp0\config\%$APPX_List%" set "$APPX_List=%~dp0\config\%$APPX_List%"
FOR /F "tokens=2 delims=^=" %%V IN ('FINDSTR /BC:"$APPX_FILE" "%~dp0\config\%$CONFIG_FILE%"') DO SET "$APPX_FILE=%%V"
echo $APPX_FILE: %$APPX_FILE%
if exist "%~dp0\config\%$APPX_FILE%" set "$APPX_FILE=%~dp0\config\%$APPX_FILE%"
:: [DELETE] Scheduled Tasks
FOR /F "tokens=2 delims=^=" %%V IN ('FINDSTR /BC:"$KEYWORD_SCHEDULED_TASK" "%~dp0\config\%$CONFIG_FILE%"') DO SET "$KEYWORD_SCHEDULED_TASK=%%V"
echo $KEYWORD_SCHEDULED_TASK: %$KEYWORD_SCHEDULED_TASK%
Expand Down Expand Up @@ -300,7 +301,9 @@ echo $IMAGE_FILE: %$IMAGE_FILE%
FOR /F "tokens=2 delims=^=" %%V IN ('FINDSTR /BC:"$IMAGE_TYPE" "%~dp0\config\%$CONFIG_FILE%"') DO SET "$IMAGE_TYPE=%%V"
echo $IMAGE_TYPE: %$IMAGE_TYPE%
echo End properties file parsing.

echo.
echo working directory:
cd

:skipCF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Expand All @@ -314,7 +317,7 @@ SET "$LD=%$WD%\%$LD%\%COMPUTERNAME%"
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:OSR
:: Windows recon
echo Windows recon...
::IF NOT EXIST "%$CACHE%\OS_Caption.txt" wmic OS GET CAPTION /VALUE > "%$CACHE%\OS_Caption.txt"
::IF NOT EXIST "%$CACHE%\OS_BuildNumber.txt" wmic OS GET BUILDNUMBER /VALUE > "%$CACHE%\OS_BuildNumber.txt"
::IF NOT EXIST "%$CACHE%\ver.txt" ver > "%$CACHE%\ver.txt"
Expand Down Expand Up @@ -350,7 +353,7 @@ SET "$LD=%$WD%\%$LD%\%COMPUTERNAME%"
IF "%USERNAME%"=="Administrator" GoTo skipUser
echo %USERNAME%> "%$CD%\Username.txt"
IF NOT DEFINED $LOCAL_USER SET /P $LOCAL_USER= < "%$CD%\Username.txt"
IF NOT "%USERNAME%"=="$LOCAL_USER" SET $LOCAL_USER=%USERNAME%
IF NOT "%USERNAME%"=="%$LOCAL_USER%" SET $LOCAL_USER=%USERNAME%
:skipUser
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Expand All @@ -365,7 +368,7 @@ IF NOT "%USERNAME%"=="$LOCAL_USER" SET $LOCAL_USER=%USERNAME%
IF %$Debug% EQU 1 echo %TIME% [DEBUG] Log directory [$LD]: %$LD% >> "%$LD%\%$MODULE_LOG%"
IF %$Debug% EQU 1 echo %TIME% [DEBUG] cache directory [$CD]: %$CD% >> "%$LD%\%$MODULE_LOG%"
IF %$Debug% EQU 1 echo %TIME% [DEBUG] $LOCAL_USER: %$LOCAL_USER% >> "%$LD%\%$MODULE_LOG%"
IF %$Debug% EQU 1 echo %TIME% [DEBUG] APPX_FILE: %$APPX_FILE% >> "%$LD%\%$MODULE_LOG%"
IF %$Debug% EQU 1 echo %TIME% [DEBUG] $APPX_FILE: %$APPX_FILE% >> "%$LD%\%$MODULE_LOG%"
IF %$Debug% EQU 1 echo %TIME% [DEBUG] $KEYWORD_SCHEDULED_TASK: %$KEYWORD_SCHEDULED_TASK% >> "%$LD%\%$MODULE_LOG%"
IF %$Debug% EQU 1 echo %TIME% [DEBUG] $NotKBArticleID: %$NotKBArticleID% >> "%$LD%\%$MODULE_LOG%"
IF %$Debug% EQU 1 echo %TIME% [DEBUG] $TIMEOUT: %$TIMEOUT% >> "%$LD%\%$MODULE_LOG%"
Expand All @@ -388,7 +391,7 @@ IF NOT "%USERNAME%"=="$LOCAL_USER" SET $LOCAL_USER=%USERNAME%


SET $BANNER=0
SET $STEP_NUM=0
SET $STEP_NUM=Main
SET "$STEP_DESCRIP=Menu selection"

:banner
Expand Down Expand Up @@ -460,7 +463,7 @@ Echo.
:: echo %$STEP_DESCRIP% Done.
:: Timeout /T %$TIMEOUT%
:::skipP#
:: SET $STEP_NUM=0
:: SET $STEP_NUM=Main
:: SET "$STEP_DESCRIP=Menu selection"
:: GoTo Menu
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Expand All @@ -487,7 +490,7 @@ Echo.
shutdown /R /T 5 /f /c "Reboot to flush logged on user profile and log in with Administrator account."
GoTo Exit
:skipP1
SET $STEP_NUM=0
SET $STEP_NUM=Main
SET "$STEP_DESCRIP=Menu selection"
GoTo Menu
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Expand Down Expand Up @@ -516,7 +519,7 @@ GoTo Menu
echo %TIME% [INFO] %$STEP_DESCRIP% completed! >> "%$LD%\%$MODULE_LOG%"
:skipP2
type "%$CD%\User_Profiles.txt" > "%$CD%\%$PROCESS_2%"
SET $STEP_NUM=0
SET $STEP_NUM=Main
SET "$STEP_DESCRIP=Menu selection"
GoTo Menu
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Expand Down Expand Up @@ -546,7 +549,7 @@ GoTo Menu
GoTo STL
:skipP3
echo %TIME% [INFO] %$PROCESS_T_3% completed! >> "%$LD%\%$MODULE_LOG%"
SET $STEP_NUM=0
SET $STEP_NUM=Main
SET "$STEP_DESCRIP=Menu selection"
GoTo Menu
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Expand All @@ -570,18 +573,18 @@ GoTo Menu
)
del /Q "%$CD%\APPX_List_FullPackage.txt" 2> nul 1> nul
del /Q "%$CD%\APPX_FullPackage_Name.txt" 2> nul 1> nul
for /f %%P in (%$APPX_LIST%) DO @powershell -command "(Get-AppxPackage %%P -allusers | Out-String -Width 100)" >> "%$CD%\APPX_FullPackage_Name.txt"
for /f %%P in (%$APPX_FILE%) DO @powershell -command "(Get-AppxPackage %%P -allusers | Out-String -Width 100)" >> "%$CD%\APPX_FullPackage_Name.txt"
FIND /I "PackageFullName" "%$CD%\APPX_FullPackage_Name.txt" >> "%$CD%\APPX_List_FullPackage.txt"
echo Removing APPX packages from APPX list...
type %$APPX_LIST%
type %$APPX_FILE%
FOR /F "skip=2 tokens=3 delims= " %%P IN (%$CD%\APPX_List_FullPackage.txt) do (
echo removing %%P
@powershell Remove-AppxPackage -AllUsers -Package %%P 2> nul
)
echo %TIME% [INFO] %$STEP_DESCRIP% completed! >> "%$LD%\%$MODULE_LOG%"
Timeout /T %$TIMEOUT%
:skipP4
SET $STEP_NUM=0
SET $STEP_NUM=Main
SET "$STEP_DESCRIP=Menu selection"
GoTo Menu
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Expand Down Expand Up @@ -626,7 +629,7 @@ GoTo Menu
echo Windows update via powershell has completed!
Timeout /T %$TIMEOUT%
:skipP5
SET $STEP_NUM=0
SET $STEP_NUM=Main
SET "$STEP_DESCRIP=Menu selection"
GoTo Menu
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Expand All @@ -646,7 +649,7 @@ GoTo Menu
echo %$STEP_DESCRIP% Done.
Timeout /T %$TIMEOUT%
:skipP6
SET $STEP_NUM=0
SET $STEP_NUM=Main
SET "$STEP_DESCRIP=Menu selection"
GoTo Menu
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Expand Down Expand Up @@ -688,7 +691,7 @@ GoTo Menu
echo %$STEP_DESCRIP% Done.
Timeout /T %$TIMEOUT%
:skipP7
SET $STEP_NUM=0
SET $STEP_NUM=Main
SET "$STEP_DESCRIP=Menu selection"
GoTo Menu
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Expand All @@ -715,7 +718,7 @@ GoTo Menu
echo %$STEP_DESCRIP% Done.
Timeout /T %$TIMEOUT%
:skipP8
SET $STEP_NUM=0
SET $STEP_NUM=Main
SET "$STEP_DESCRIP=Menu selection"
GoTo Menu
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Expand All @@ -735,7 +738,7 @@ GoTo Menu
echo %$STEP_DESCRIP% Done.
GoTo exit
:skipP9
SET $STEP_NUM=0
SET $STEP_NUM=Main
SET "$STEP_DESCRIP=Menu selection"
GoTo Menu
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Expand Down Expand Up @@ -797,7 +800,7 @@ GoTo Menu
IF %$SYSPREP_ERROR% EQU 1 GoTo sysprepE1
IF %$SYSPREP_ERROR% EQU 0 GoTo exit
:skipP0
SET $STEP_NUM=0
SET $STEP_NUM=Main
SET "$STEP_DESCRIP=Menu selection"
GoTo Menu
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Expand Down

0 comments on commit 11b3c81

Please sign in to comment.