Skip to content

Commit ea0b8fb

Browse files
committed
fix: harden services-stage indexing and file-sharing scripts
1 parent b835303 commit ea0b8fb

File tree

12 files changed

+86
-36
lines changed

12 files changed

+86
-36
lines changed

src/playbook/Configuration/atlas/appx.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ actions:
9191
# Clear caches of Client.CBS and more
9292
# Start menu cache is cleared later
9393
- !writeStatus: {status: 'Clearing AppX caches'}
94+
- !taskKill: {name: 'SearchHost*', ignoreErrors: true}
95+
- !taskKill: {name: 'SearchApp*', ignoreErrors: true}
9496
- !appx: {operation: clearCache, name: '*MicrosoftWindows.Client.CBS*'}
9597
- !appx: {operation: clearCache, name: '*Microsoft.Windows.Search*'}
9698
- !appx: {operation: clearCache, name: '*Microsoft.Windows.SecHealthUI*'}

src/playbook/Configuration/atlas/default.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Run default AtlasFolder scripts
44
actions:
55
- !writeStatus: {status: 'Applying default Atlas Folder settings'}
66
- !cmd:
7-
command: 'reg import .\DEFAULT.reg'
7+
command: 'cmd /c "reg import .\DEFAULT.reg > nul 2>&1"'
88
exeDir: true
99
wait: true
1010
onUpgrade: false

src/playbook/Configuration/atlas/services.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ actions:
3030
runas: currentUserElevated
3131

3232
- !writeStatus: {status: 'Disabling Location'}
33-
- !cmd:
34-
command: '"AtlasDesktop\3. General Configuration\Location\Disable Location (default).cmd" /silent'
33+
- !powerShell:
34+
command: |
35+
& "$env:windir\AtlasDesktop\3. General Configuration\Location\Disable Location (default).cmd" /silent
3536
exeDir: true
3637
wait: true
3738
runas: currentUserElevated
3839

3940
- !writeStatus: {status: 'Configuring Indexing'}
40-
- !cmd:
41-
command: '"AtlasDesktop\3. General Configuration\Search Indexing\Minimal Search Indexing (default).cmd" /silent'
41+
- !powerShell:
42+
command: |
43+
& "$env:windir\AtlasDesktop\3. General Configuration\Search Indexing\Minimal Search Indexing (default).cmd" /silent
4244
exeDir: true
4345
wait: true
4446
runas: currentUserElevated
@@ -57,7 +59,7 @@ actions:
5759

5860
# ------ Microsoft recommendation - 'Do not disable' -----
5961
- !service: {name: 'diagnosticshub.standardcollector.service', operation: change, startup: 4}
60-
- !service: {name: 'WerSvc', operation: change, startup: 4}
62+
- !service: {name: 'WerSvc', operation: change, startup: 4}
6163

6264
# ------- Microsoft recommendation - 'No guidance' ------
6365
- !service: {name: 'wercplsupport', operation: change, startup: 4}

src/playbook/Executables/AtlasDesktop/3. General Configuration/File Sharing/Disable File Sharing (default).cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fltmc > nul 2>&1 || (
2525
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v state /t REG_DWORD /d %stateValue% /f > nul
2626
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v path /t REG_SZ /d "%scriptPath%" /f > nul
2727

28-
powershell -EP Bypass -NoP -File "%script%"
28+
powershell -EP RemoteSigned -NoP -File "%script%"
2929
if "%~1"=="/silent" exit /b
3030

3131
choice /c:yn /n /m "Finished, would you like to restart now to apply the changes? [Y/N] "

src/playbook/Executables/AtlasDesktop/3. General Configuration/File Sharing/Enable File Sharing.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fltmc > nul 2>&1 || (
2525
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v state /t REG_DWORD /d %stateValue% /f > nul
2626
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v path /t REG_SZ /d "%scriptPath%" /f > nul
2727

28-
powershell -EP Bypass -NoP -File "%script%"
28+
powershell -EP RemoteSigned -NoP -File "%script%"
2929
if "%~1"=="/silent" exit /b
3030

3131
choice /c:yn /n /m "Finished, would you like to restart now to apply the changes? [Y/N] "

src/playbook/Executables/AtlasDesktop/3. General Configuration/File Sharing/Give Access To Menu/Enable Give Access To Menu.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v path /t REG_SZ /d "%sc
2626
reg add "HKEY_CLASSES_ROOT\UserLibraryFolder\shellex\ContextMenuHandlers\Sharing" /ve /t REG_SZ /d "{f81e9010-6ea4-11ce-a7ff-00aa003ca9f6}" /f
2727
) > nul 2>&1
2828

29+
if "%~1"=="/silent" exit /b
30+
2931
echo Finished, 'Give Access To' menu is now enabled.
3032
pause > nul
3133
exit /b

src/playbook/Executables/AtlasDesktop/3. General Configuration/Power-saving/Default Power-saving (default).cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if not exist "%script%" (
2525
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v state /t REG_DWORD /d %stateValue% /f > nul
2626
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v path /t REG_SZ /d "%scriptPath%" /f > nul
2727

28-
powershell -EP Bypass -NoP -File "%script%" %* -Silent
28+
powershell -EP RemoteSigned -NoP -File "%script%" %* -Silent
2929

3030
if "%~1"=="/silent" exit /b
3131

src/playbook/Executables/AtlasDesktop/3. General Configuration/Search Indexing/Disable Search Indexing.cmd

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,20 @@ set "settingName=Indexing"
33
set "stateValue=0"
44
set "scriptPath=%~f0"
55
set indexConfPath="%windir%\AtlasModules\Scripts\indexConf.cmd"
6+
set "silentMode=0"
67

7-
whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
8-
call RunAsTI.cmd "%~f0" %*
9-
exit /b
8+
echo %* | findstr /i /c:"/silent" /c:"-silent" /c:"/quiet" > nul 2>&1 && set "silentMode=1"
9+
10+
if "%silentMode%"=="1" (
11+
fltmc > nul 2>&1 || (
12+
call RunAsTI.cmd "%~f0" %*
13+
exit /b
14+
)
15+
) else (
16+
whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
17+
call RunAsTI.cmd "%~f0" %*
18+
exit /b
19+
)
1020
)
1121

1222
if not exist "%indexConfPath%" (
@@ -23,6 +33,8 @@ echo.
2333
echo Disabling search indexing...
2434
%indexConf% /stop
2535

36+
if "%silentMode%"=="1" exit /b
37+
2638
echo.
2739
echo Search Indexing has been disabled.
2840
echo Press any key to exit...

src/playbook/Executables/AtlasDesktop/3. General Configuration/Search Indexing/Enable Search Indexing.cmd

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,20 @@ set "settingName=Indexing"
33
set "stateValue=2"
44
set "scriptPath=%~f0"
55
set indexConfPath="%windir%\AtlasModules\Scripts\indexConf.cmd"
6+
set "silentMode=0"
67

7-
whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
8-
call RunAsTI.cmd "%~f0" %*
9-
exit /b
8+
echo %* | findstr /i /c:"/silent" /c:"-silent" /c:"/quiet" > nul 2>&1 && set "silentMode=1"
9+
10+
if "%silentMode%"=="1" (
11+
fltmc > nul 2>&1 || (
12+
call RunAsTI.cmd "%~f0" %*
13+
exit /b
14+
)
15+
) else (
16+
whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
17+
call RunAsTI.cmd "%~f0" %*
18+
exit /b
19+
)
1020
)
1121

1222
if not exist "%indexConfPath%" (
@@ -41,7 +51,7 @@ for /f "usebackq delims=" %%a in (`dir /b /a:d "%SystemDrive%\Users"`) do (
4151
reg add "HKLM\SOFTWARE\Microsoft\Windows Search" /v SetupCompletedSuccessfully /t REG_DWORD /d 0 /f > nul
4252

4353
set regCmd=^>nul reg add "HKLM\Software\Microsoft\Windows Search\Gather\Windows\SystemIndex" /v "RespectPowerModes" /t REG_DWORD /d
44-
if "%~1"=="/silent" (%regCmd% "0" /f & exit /b)
54+
if "%silentMode%"=="1" (%regCmd% "0" /f & exit /b)
4555

4656
echo.
4757
:: Respect Power Settings when Search Indexing to prevent performance loss during gaming or battery drain

src/playbook/Executables/AtlasDesktop/3. General Configuration/Search Indexing/Minimal Search Indexing (default).cmd

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,25 @@ set "settingName=Indexing"
33
set "stateValue=1"
44
set "scriptPath=%~f0"
55
set indexConfPath="%windir%\AtlasModules\Scripts\indexConf.cmd"
6-
7-
whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
8-
call RunAsTI.cmd "%~f0" %*
9-
exit /b
6+
set "silentMode=0"
7+
8+
echo %* | findstr /i /c:"/silent" /c:"-silent" /c:"/quiet" > nul 2>&1 && set "silentMode=1"
9+
10+
if "%silentMode%"=="1" (
11+
fltmc > nul 2>&1 || (
12+
call RunAsTI.cmd "%~f0" %*
13+
exit /b
14+
)
15+
) else (
16+
whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
17+
call RunAsTI.cmd "%~f0" %*
18+
exit /b
19+
)
1020
)
1121

1222
if not exist "%indexConfPath%" (
1323
echo The 'indexConf.cmd' script wasn't found in AtlasModules.
24+
if "%silentMode%"=="1" exit /b 1
1425
pause
1526
exit /b 1
1627
)
@@ -19,8 +30,10 @@ set "indexConf=call %indexConfPath%"
1930
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v state /t REG_DWORD /d %stateValue% /f > nul
2031
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v path /t REG_SZ /d "%scriptPath%" /f > nul
2132

22-
echo.
23-
echo Configuring minimal search indexing...
33+
if "%silentMode%"=="0" (
34+
echo.
35+
echo Configuring minimal search indexing...
36+
)
2437
%indexConf% /stop
2538
%indexConf% /cleanpolicies
2639
%indexConf% /include "%programdata%\Microsoft\Windows\Start Menu\Programs"
@@ -32,7 +45,7 @@ reg add "HKLM\Software\Microsoft\Windows Search\Gather\Windows\SystemIndex" /v "
3245
%indexConf% /start
3346
reg add "HKLM\SOFTWARE\Microsoft\Windows Search" /v SetupCompletedSuccessfully /t REG_DWORD /d 0 /f > nul
3447

35-
if "%~1"=="/silent" exit /b
48+
if "%silentMode%"=="1" exit /b
3649

3750
echo.
3851
echo Minimal Search Indexing has been configured.

0 commit comments

Comments
 (0)