Auto-commit: 2025-10-31 08:58:35
This commit is contained in:
18
Windows-ScriptUpgrade/readme.md
Normal file
18
Windows-ScriptUpgrade/readme.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# ⬆️ Windows 11 In-Place Upgrade (Batch)
|
||||
|
||||
## 🔧 What it does
|
||||
- Prepares folders and log (`C:\exploit\log\migrationw11.log`)
|
||||
- Runs **pending reboot check** (`upgrade_GetPendingReboot.cmd`) and **cleanup** (`upgrade_Cleanup.cmd`)
|
||||
- Sets PowerShell **ExecutionPolicy Bypass**
|
||||
- Detects OS **UI culture** and selects **install.wim index** (EN/ES/FR/IT/PT)
|
||||
- Launches `setup.exe` **/quiet /auto Upgrade** using local `install.wim`, installs drivers from `C:\pnpdrivers`, **DynamicUpdate Disabled**, runs `upgrade_setupcomplete.cmd` at OOBE
|
||||
- Reports status to **LANDesk/LDMS** via `SendTaskStatus.exe`
|
||||
- Logs return code and removes `C:\MigrationW11` on failure
|
||||
|
||||
## ✅ Prerequisites
|
||||
- Run as **Administrator**
|
||||
- The script’s folder (`%~dp0`) must contain **Windows Setup**: `setup.exe`, `sources\install.wim`, and `upgrade_setupcomplete.cmd`
|
||||
- Companion scripts present: `upgrade_GetPendingReboot.cmd`, `upgrade_Cleanup.cmd`
|
||||
- **Drivers** in `C:\pnpdrivers`
|
||||
- **LDMS** vars available: `LDMS_LOCAL_DIR`, `task_ID`; server name set in script (`ldcore.kiabi.fr`)
|
||||
- Sufficient disk space; **no reboot pending**; network not required (DynamicUpdate disabled)
|
||||
28
Windows-ScriptUpgrade/upgrade_Cleanup.cmd
Normal file
28
Windows-ScriptUpgrade/upgrade_Cleanup.cmd
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
:CleanupLandesk
|
||||
@echo off
|
||||
del "C:\Program Files (x86)\LANDesk\LDClient\sdmcache\*.msu" /q
|
||||
rd "C:\Program Files (x86)\LANDesk\LDClient\sdmcache\refinst\packageW7" /s /q
|
||||
rd "C:\Program Files (x86)\LANDesk\LDClient\sdmcache\refinst\ToolsW7\" /s /q
|
||||
rd "C:\Program Files (x86)\LANDesk\LDClient\sdmcache\refinst\SCX\packageW7" /s /q
|
||||
rd "C:\Program Files (x86)\LANDesk\LDClient\sdmcache\refinst\SCX\ToolsW7\PnPDrivers" /s /q
|
||||
rd "C:\Program Files (x86)\LANDesk\LDClient\sdmcache\refinst\KISS\packageW7" /s /q
|
||||
rd "C:\Program Files (x86)\LANDesk\LDClient\sdmcache\refinst\KISS\ToolsW7\PnPDrivers" /s /q
|
||||
rd "C:\Program Files (x86)\LANDesk\LDClient\sdmcache\refinst\Log\packageW7" /s /q
|
||||
rd "C:\Program Files (x86)\LANDesk\LDClient\sdmcache\refinst\Log\ToolsW7\PnPDrivers" /s /q
|
||||
|
||||
|
||||
:CleanupChrome
|
||||
@echo on
|
||||
cd /d C:\Users
|
||||
for /d %%z in (C:\Users\*) do (
|
||||
del %%z\AppData\Local\Temp\* /S /Q
|
||||
for /d %%y in (%%z\AppData\Local\Temp\*) do @rd /s /q "%%y"
|
||||
del "%%z\AppData\Local\Google\Chrome\User Data\Default\*.tmp" /S /Q
|
||||
del "%%z\AppData\Local\Google\Chrome\User Data\Default\Cache\*" /S /Q
|
||||
del "%%z\AppData\Local\Google\Chrome\User Data\Default\Application Cache\Cache\*" /S /Q
|
||||
del "%%z\AppData\Local\Google\Chrome\User Data\Default\GPUCache\*" /S /Q
|
||||
del "%%z\AppData\Local\Google\Chrome\User Data\Default\Media Cache\*" /S /Q
|
||||
del "%%z\AppData\Local\Microsoft\Windows\Temporary Internet Files\*" /S /Q
|
||||
)
|
||||
|
||||
33
Windows-ScriptUpgrade/upgrade_GetPendingReboot.cmd
Normal file
33
Windows-ScriptUpgrade/upgrade_GetPendingReboot.cmd
Normal file
@@ -0,0 +1,33 @@
|
||||
:InitSynative
|
||||
@echo off
|
||||
Set cmdreg=reg
|
||||
if defined PROCESSOR_ARCHITEW6432 Set cmdreg=%SystemRoot%\sysnative\reg.exe
|
||||
|
||||
:GetPendingReboot
|
||||
%cmdreg% query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations
|
||||
if %ERRORLEVEL% EQU 0 goto PassReboot
|
||||
%cmdreg% query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing" /v RebootPending
|
||||
if %ERRORLEVEL% EQU 0 goto PassReboot
|
||||
%cmdreg% query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v RebootRequired
|
||||
if %ERRORLEVEL% EQU 0 goto PassReboot
|
||||
%cmdreg% query "HKLM\SOFTWARE\Wow6432Node\landesk\managementsuite\WinClient\VulscanReboot"
|
||||
if %ERRORLEVEL% EQU 0 goto PassReboot
|
||||
|
||||
:GetWindowsold
|
||||
::If exist "c:\Windows.old" goto PassWindowsold
|
||||
|
||||
Goto OKcontinue
|
||||
|
||||
:PassReboot
|
||||
echo ********** PendingReboot ********************************
|
||||
timeout 30
|
||||
Exit /B 1000
|
||||
|
||||
:PassWindowsold
|
||||
echo ********** Windowsold ********************************
|
||||
timeout 30
|
||||
Exit /B 1002
|
||||
|
||||
:OKcontinue
|
||||
echo No Pending Reboot
|
||||
Exit /B 0
|
||||
2
Windows-ScriptUpgrade/upgrade_GetWim.cmd
Normal file
2
Windows-ScriptUpgrade/upgrade_GetWim.cmd
Normal file
@@ -0,0 +1,2 @@
|
||||
DISM /Get-WimInfo /WimFile:"%~dp0sources\install.wim"
|
||||
pause
|
||||
58
Windows-ScriptUpgrade/upgrade_Install.cmd
Normal file
58
Windows-ScriptUpgrade/upgrade_Install.cmd
Normal file
@@ -0,0 +1,58 @@
|
||||
Set LogFile=c:\windows\temp\migrationw11.log
|
||||
Set LDMSserver=ldcore.monlab.lan
|
||||
md c:\exploit
|
||||
md c:\exploit\log
|
||||
md c:\pnpdrivers
|
||||
set SourceISO=%~dp0
|
||||
|
||||
Set cmdreg=reg
|
||||
Set cmdpowershell=powershell
|
||||
Set cmddism=dism
|
||||
if defined PROCESSOR_ARCHITEW6432 Set cmdreg=%SystemRoot%\sysnative\reg.exe
|
||||
if defined PROCESSOR_ARCHITEW6432 Set cmdpowershell=%SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe
|
||||
if defined PROCESSOR_ARCHITEW6432 Set cmddism=%SystemRoot%\Sysnative\cmd.exe /c Dism
|
||||
|
||||
:Preparation
|
||||
call "%~dp0upgrade_GetPendingReboot.cmd"
|
||||
if %ERRORLEVEL% NEQ 0 Exit /B %ERRORLEVEL%
|
||||
%cmdpowershell% -noprofile -command "set-executionPolicy Bypass localmachine"
|
||||
call "%~dp0upgrade_Cleanup.cmd"
|
||||
|
||||
echo ---------------- UPGRADE %date% %time%--------------------------------->>%LogFile%
|
||||
:: ################# Set WimFile and Index ###################
|
||||
|
||||
:InitCulture
|
||||
echo InitCulture>>%LogFile%
|
||||
:: Get culture du poste
|
||||
%cmdpowershell% -command [CultureInfo]::InstalledUICulture.Name>c:\windows\temp\InstalledUICulture.txt
|
||||
set /p culture= < c:\windows\temp\InstalledUICulture.txt
|
||||
findstr /m "CultureInfo" c:\windows\temp\InstalledUICulture.txt
|
||||
IF %ERRORLEVEL% EQU 0 set culture=%Language%
|
||||
|
||||
Set IndexWIM=0
|
||||
IF /I %culture% EQU en-US Set IndexWIM=1
|
||||
IF /I %culture% EQU es-ES Set IndexWIM=2
|
||||
IF /I %culture% EQU fr-FR Set IndexWIM=3
|
||||
IF /I %culture% EQU it-IT Set IndexWIM=4
|
||||
IF /I %culture% EQU pt-PT Set IndexWIM=5
|
||||
echo IndexWIM=%IndexWIM%
|
||||
echo IndexWIM=%IndexWIM% >>%LogFile%
|
||||
|
||||
|
||||
:StartSetup
|
||||
echo StartSetup>>%LogFile%
|
||||
@echo off
|
||||
"%LDMS_LOCAL_DIR%\..\SendTaskStatus.exe" -core=%LDMSserver% -taskid=%task_ID% -retcode=%errorlevel% -message=Setupexe
|
||||
echo setupexe ="%SourceISO%setup.exe"
|
||||
"%SourceISO%setup.exe" /quiet /EULA accept /noreboot /auto Upgrade /installfrom "%SourceISO%sources\install.wim" /imageindex %IndexWIM% /installdrivers c:\pnpdrivers /DynamicUpdate Disable /postoobe "%SourceISO%upgrade_setupcomplete.cmd"
|
||||
Set RetourCode=%errorlevel%
|
||||
|
||||
|
||||
:Fin
|
||||
echo Fin>>%LogFile%
|
||||
@echo off
|
||||
Echo RetourCode=%RetourCode%
|
||||
Echo RetourCode=%RetourCode% >>%LogFile%
|
||||
"%LDMS_LOCAL_DIR%\..\SendTaskStatus.exe" -core=%LDMSserver% -taskid=%task_ID% -retcode=%RetourCode% -message=%RetourCode%
|
||||
if %RetourCode% NEQ 0 rd c:\MigrationW11 /S /Q
|
||||
::Exit /B %RetourCode%
|
||||
12
Windows-ScriptUpgrade/upgrade_setupcomplete.cmd
Normal file
12
Windows-ScriptUpgrade/upgrade_setupcomplete.cmd
Normal file
@@ -0,0 +1,12 @@
|
||||
if exist c:\migrationW10\boot rd c:\migrationW10\boot /S /Q
|
||||
if exist c:\migrationW10\efi rd c:\migrationW10\efi /S /Q
|
||||
if exist c:\migrationW10\sources rd c:\migrationW10\sources /S /Q
|
||||
if exist c:\migrationW10\support rd c:\migrationW10\support /S /Q
|
||||
if exist c:\migrationW11\boot rd c:\migrationW11\boot /S /Q
|
||||
if exist c:\migrationW11\efi rd c:\migrationW11\efi /S /Q
|
||||
if exist c:\migrationW11\sources rd c:\migrationW11\sources /S /Q
|
||||
if exist c:\migrationW11\support rd c:\migrationW11\support /S /Q
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user