-
-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(post-install env): init packages script
- Loading branch information
Showing
7 changed files
with
190 additions
and
24 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/playbook/Executables/AtlasModules/Other/recovery/atlas/hta/data.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
.dataButton::after{content:"INFO;Starting up;1"} | ||
.dataButton::after{content:"INFO;Getting ready;1"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 123 additions & 3 deletions
126
src/playbook/Executables/AtlasModules/Other/recovery/atlas/packages.cmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,125 @@ | ||
@echo off | ||
cd /d "%~dp0" | ||
echo hi | ||
start | ||
pause | ||
for %%a in ( | ||
log | ||
setInfo | ||
wait | ||
addPackage | ||
) do ( | ||
set %%a=call :%%a | ||
) | ||
:: Set to 'High Performance' power plan | ||
powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c | ||
|
||
:: ======================================================================================================================= :: | ||
:: VARIABLES :: | ||
:: ======================================================================================================================= :: | ||
|
||
echo INFO: Setting variables... | ||
|
||
:: Set target drive | ||
set "targetDrive=C:" | ||
|
||
:: HTA | ||
set "htaFolderPath=%cd%\hta" | ||
set "htaPath=%htaFolderPath%\hta.html" | ||
set "dataPath=%htaFolderPath%\data.css" | ||
|
||
:: Target disk variables | ||
set "packagesList=%targetDrive%\Windows\AtlasModules\packagestoInstall" | ||
set "atlasLogDirectory=%targetDrive%\Windows\AtlasModules\Logs" | ||
|
||
:: Other variables | ||
set "percentage=1" | ||
|
||
:: Set log file | ||
echo INFO: Setting log file... | ||
if not exist "%atlasLogDirectory%" mkdir "%atlasLogDirectory%" & echo Made Atlas log directory... | ||
:makeLogDirectoryAndFile | ||
set /a logNum += 1 | ||
set "logDirPath=%atlasLogDirectory%\%logNum%-AtlasPackageInstall-%date:/=-%" | ||
if exist "%logDirPath%" (goto makeLogDirectoryAndFile) else ( | ||
mkdir "%logDirPath%" | ||
set "logPath=%logDirPath%\dism.log" | ||
) | ||
|
||
echo INFO: Starting debug console... | ||
start /i /d "%targetDrive%\Windows" /min "Atlas Debug Console" cmd /k set "log=notepad %logPath%" ^& cls ^& echo Type %%log%% to open the log. | ||
|
||
:: -------------------------------------------------------------------------------------------------------- :: | ||
:: Start looping through packages :: | ||
:: -------------------------------------------------------------------------------------------------------- :: | ||
|
||
for /f "usebackq" %%a in (`type "%packagesList%" ^| find "" /v /c`) do set packageCount=%%a | ||
%log% "INFO: Installing %packageCount% packages from %packagesList%..." | ||
set /a percentageSteps=100/%packageCount% | ||
for /f "tokens=* delims=" %%a in (%packagesList%) do ( | ||
%addPackage% "%%a" | ||
) | ||
|
||
:: -------------------------------------------------------------------------------------------------------- :: | ||
:: Finsh up :: | ||
:: -------------------------------------------------------------------------------------------------------- :: | ||
|
||
echo INFO: Finishing up | ||
%setInfo% "Restarting" "100" | ||
|
||
if defined error echo "%logPath%" "%error%" > "%targetDrive%\Windows\System32\AtlasPackagesFailure" | ||
copy /y "%packagesList%" "%logDirPath%" | ||
del /f /q "%packagesList%" | ||
|
||
%wait% 6 | ||
wpeutil reboot | ||
|
||
:: ======================================================================================================================= :: | ||
:: FUNCTIONS :: | ||
:: ======================================================================================================================= :: | ||
exit /b | ||
|
||
:addPackage [packagePath] | ||
set /a packageNum += 1 | ||
set /a halfWayPercentage = %percentage% + ( %percentageSteps% / 2 ) | ||
|
||
set "dismCurrentLog=%logDirPath%\dismTemp%random%.txt" | ||
set "dismCommand=dism /image:%targetDrive%\ /add-package:"%targetDrive%\%~1" /logpath:"%dismCurrentLog%"" | ||
%log% "%dismCommand%" | ||
%setInfo% "Adding package %packageNum%" "%halfWayPercentage%" | ||
|
||
%dismCommand% | ||
set dismErrorlevel=%errorlevel% | ||
if %dismErrorlevel%==0 ( | ||
%log% "SUCCESS: Successfully deployed %~1..." | ||
type "%dismCurrentLog%" >> "%logPath%" | ||
) else ( | ||
%log% "ERROR: Failed to deploy %~1! Exit code %dismErrorLevel%." | ||
set error=%dismErrorlevel% | ||
) | ||
del /f /q "%dismCurrentLog%" | ||
|
||
set /a percentage=%percentage% + %percentageSteps% | ||
%setInfo% "Adding package %packageNum%" "%percentage%" | ||
exit /b | ||
|
||
:log [text] | ||
( | ||
echo] | ||
echo ================================================================================================================================== | ||
echo %~1 | ||
echo ================================================================================================================================== | ||
echo] | ||
) >> "%logPath%" | ||
echo %~1 | ||
exit /b | ||
|
||
:setInfo [message] [percentage] | ||
echo .dataButton::after{content:"INFO;%~1;%~2"} > "%dataPath%" | ||
exit /b | ||
|
||
:: :setError [message] | ||
:: echo .dataButton::after{content:"ERROR;%~1"} > "%dataPath%" | ||
:: exit /b | ||
|
||
:wait [seconds] | ||
set /a timeInMs=%~1 * 1000 | ||
cscript %cd%\sleep.vbs %timeInMs% //B | ||
exit /b |
1 change: 1 addition & 0 deletions
1
src/playbook/Executables/AtlasModules/Other/recovery/atlas/sleep.vbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
WScript.Sleep WScript.Arguments(0) |
31 changes: 31 additions & 0 deletions
31
src/playbook/Executables/AtlasModules/Other/recovery/atlas/startup.vbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Set objFSO = CreateObject("Scripting.FileSystemObject") | ||
Set objShell = CreateObject("WScript.Shell") | ||
systemDrive = objShell.ExpandEnvironmentStrings("%SystemDrive%") | ||
|
||
strHTAPath = systemDrive & "\atlas\hta\hta.html" | ||
Dim objProcess, strHTAPath, bHTARunning | ||
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") | ||
|
||
If objFSO.FileExists("C:\Windows\AtlasModules\packagestoInstall") Then | ||
objShell.Run systemDrive & "\atlas\packages.cmd", 0 | ||
Else | ||
objShell.Run systemDrive & "\sources\recovery\RecEnv.exe", 1 | ||
End If | ||
|
||
Do | ||
bHTARunning = False | ||
For Each objProcess in objWMIService.ExecQuery("Select * from Win32_Process") | ||
If LCase(objProcess.Name) = "mshta.exe" Then | ||
If InStr(1, objProcess.CommandLine, strHTAPath, vbTextCompare) > 0 Then | ||
bHTARunning = True | ||
Exit For | ||
End If | ||
End If | ||
Next | ||
|
||
If Not bHTARunning Then | ||
objShell.Run "mshta " & strHTAPath | ||
End If | ||
|
||
WScript.Sleep 3000 | ||
Loop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Windows\AtlasModules\Packages\Z-Atlas-NoDefender-Package31bf3856ad364e35amd643.0.0.0.cab | ||
Windows\AtlasModules\Packages\Z-Atlas-Misc-Remover-Package31bf3856ad364e35amd643.0.0.0.cab | ||
Windows\AtlasModules\Packages\Z-Atlas-NoTelemetry-Package31bf3856ad364e35amd643.0.0.0.cab |