-
-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make indexing minimal by default instead of disabled (#1151)
- Loading branch information
Showing
7 changed files
with
219 additions
and
34 deletions.
There are no files selected for viewing
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
21 changes: 0 additions & 21 deletions
21
...lasDesktop/3. General Configuration/Search Indexing/Disable Search Indexing (default).cmd
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
...utables/AtlasDesktop/3. General Configuration/Search Indexing/Disable Search Indexing.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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@echo off | ||
setlocal EnableDelayedExpansion | ||
set indexConfPath="%windir%\AtlasModules\Scripts\indexConf.cmd" | ||
if not exist %indexConfPath% ( | ||
echo The 'indexConf.cmd' script wasn't found in AtlasModules. | ||
if "%~1"=="" pause | ||
exit /b 1 | ||
) | ||
set "indexConf=call %indexConfPath%" | ||
|
||
if "%~1" neq "" goto main | ||
set "___args="%~f0" %*" | ||
fltmc > nul 2>&1 || ( | ||
echo Administrator privileges are required. | ||
powershell -c "Start-Process -Verb RunAs -FilePath 'cmd' -ArgumentList """/c $env:___args"""" 2> nul || ( | ||
echo You must run this script as admin. | ||
if "%*"=="" pause | ||
exit /b 1 | ||
) | ||
exit /b | ||
) | ||
|
||
:main | ||
echo =================================== | ||
echo Disabling search indexing... | ||
echo =================================== | ||
echo] | ||
|
||
%indexConf% /stop | ||
|
||
echo] | ||
echo Finished. | ||
if "%~1" neq "/silent" pause | ||
exit /b |
51 changes: 41 additions & 10 deletions
51
...cutables/AtlasDesktop/3. General Configuration/Search Indexing/Enable Search Indexing.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,24 +1,55 @@ | ||
@echo off | ||
setlocal EnableDelayedExpansion | ||
if "%~1"=="/silent" goto main | ||
set indexConfPath="%windir%\AtlasModules\Scripts\indexConf.cmd" | ||
if not exist %indexConfPath% ( | ||
echo The 'indexConf.cmd' script wasn't found in AtlasModules. | ||
if "%~1"=="" pause | ||
exit /b 1 | ||
) | ||
set "indexConf=call %indexConfPath%" | ||
|
||
if "%~1" neq "" goto main | ||
:: TI required for RespectPowerModes | ||
whoami /user | find /i "S-1-5-18" > nul 2>&1 || ( | ||
call RunAsTI.cmd "%~f0" %* | ||
exit /b | ||
) | ||
|
||
:main | ||
( | ||
sc config WSearch start=auto | ||
sc start WSearch | ||
) > nul | ||
call "%windir%\AtlasModules\Scripts\settingsPages.cmd" /unhide cortana-windowssearch | ||
echo =================================== | ||
echo Enabling search indexing... | ||
echo =================================== | ||
echo] | ||
|
||
%indexConf% /stop | ||
|
||
%indexConf% /cleanpolicies | ||
%indexConf% /include "%programdata%\Microsoft\Windows\Start Menu\Programs" | ||
:: The Atlas folder is so that if the user searches for a Atlas-modified feature, a script shows up in search | ||
%indexConf% /include "%windir%\AtlasDesktop" | ||
%indexConf% /include "%systemdrive%\Users" | ||
:: Add default user exclusions | ||
for /f "usebackq delims=" %%a in (`dir /b /a:d "%SystemDrive%\Users"`) do ( | ||
for %%z in ( | ||
"AppData" | ||
"MicrosoftEdgeBackups" | ||
) do ( | ||
if exist "%SystemDrive%\Users\%%~a\%%~z" %indexConf% /exclude "%SystemDrive%\Users\%%~a\%%~z" | ||
) | ||
) | ||
|
||
%indexConf% /start | ||
reg add "HKLM\SOFTWARE\Microsoft\Windows Search" /v SetupCompletedSuccessfully /t REG_DWORD /d 0 /f > nul | ||
|
||
set regCmd=^>nul reg add "HKLM\Software\Microsoft\Windows Search\Gather\Windows\SystemIndex" /v "RespectPowerModes" /t REG_DWORD /d | ||
if "%~1"=="/silent" (%regCmd% "0" /f & exit /b) | ||
|
||
:: Respect Power Settings when Search Indexing to prevent performance loss during gaming or other high-performance tasks | ||
reg add "HKLM\Software\Microsoft\Windows Search\Gather\Windows\SystemIndex" /v "RespectPowerModes" /t REG_DWORD /d "1" /f | ||
echo] | ||
:: Respect Power Settings when Search Indexing to prevent performance loss during gaming or battery drain | ||
choice /c:yn /n /m "Would you like to have indexing disable its self when on battery or gaming? [Y/N] " | ||
if %errorlevel%==1 %regCmd% "1" /f | ||
if %errorlevel%==2 %regCmd% "0" /f | ||
|
||
if "%~1"=="/silent" exit /b | ||
echo Finished, please reboot your device for changes to apply. | ||
echo Finished, there might be some CPU usage for a period while indexing. | ||
pause | ||
exit /b |
43 changes: 43 additions & 0 deletions
43
...lasDesktop/3. General Configuration/Search Indexing/Minimal Search Indexing (default).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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
@echo off | ||
setlocal EnableDelayedExpansion | ||
set indexConfPath="%windir%\AtlasModules\Scripts\indexConf.cmd" | ||
if not exist %indexConfPath% ( | ||
echo The 'indexConf.cmd' script wasn't found in AtlasModules. | ||
if "%~1"=="" pause | ||
exit /b 1 | ||
) | ||
set "indexConf=call %indexConfPath%" | ||
|
||
if "%~1" neq "" goto main | ||
:: TI required for RespectPowerModes | ||
whoami /user | find /i "S-1-5-18" > nul 2>&1 || ( | ||
call RunAsTI.cmd "%~f0" %* | ||
exit /b | ||
) | ||
|
||
:main | ||
echo =================================== | ||
echo Making search indexing minimal... | ||
echo This means no user folder indexing. | ||
echo =================================== | ||
echo] | ||
|
||
%indexConf% /stop | ||
|
||
%indexConf% /cleanpolicies | ||
:: Add only the Start Menu and AtlasDesktop paths by default | ||
:: The Atlas folder is so that if the user searches for a Atlas-modified feature, a script shows up in search | ||
%indexConf% /include "%programdata%\Microsoft\Windows\Start Menu\Programs" | ||
%indexConf% /include "%windir%\AtlasDesktop" | ||
%indexConf% /exclude "%systemdrive%\Users" | ||
|
||
:: Respect Power Settings when Search Indexing to prevent performance loss during gaming or battery drain | ||
reg add "HKLM\Software\Microsoft\Windows Search\Gather\Windows\SystemIndex" /v "RespectPowerModes" /t REG_DWORD /d 1 /f > nul | ||
|
||
%indexConf% /start | ||
reg add "HKLM\SOFTWARE\Microsoft\Windows Search" /v SetupCompletedSuccessfully /t REG_DWORD /d 0 /f > nul | ||
|
||
echo] | ||
echo Finished, there might be some CPU usage for a very small period while indexing. | ||
if "%~1" neq "/silent" pause | ||
exit /b |
93 changes: 93 additions & 0 deletions
93
src/playbook/Executables/AtlasModules/Scripts/indexConf.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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
@echo off | ||
|
||
fltmc > nul 2>&1 || (echo You must run this script as admin. & exit /b) | ||
set ___settings=call "%windir%\AtlasModules\Scripts\settingsPages.cmd" | ||
|
||
|
||
:: Check args | ||
set ___policy= | ||
if "%~1"=="" goto help | ||
echo %1 | find "clude" > nul && ( | ||
if "%~2"=="" goto help | ||
set ___policy=true | ||
) | ||
|
||
:: /include & /exclude | ||
if defined ___policy ( | ||
call :addIndexPath %~1 "%~2" | ||
) | ||
|
||
if "%~1"=="/cleanpolicies" ( | ||
echo Cleaning policies... | ||
for %%a in ( | ||
"HKLM\Software\Policies\Microsoft\Windows\Windows Search\DefaultExcludedPaths" | ||
"HKLM\Software\Policies\Microsoft\Windows\Windows Search\DefaultIndexedPaths" | ||
"HKLM\Software\Microsoft\Windows Search\CurrentPolicies\DefaultExcludedPaths" | ||
"HKLM\Software\Microsoft\Windows Search\CurrentPolicies\DefaultIndexedPaths" | ||
) do ( | ||
reg delete %%a /f > nul 2>&1 | ||
reg add %%a /f > nul | ||
) | ||
) | ||
|
||
if "%~1"=="/start" ( | ||
echo Starting the indexer... | ||
sc config WSearch start=delayed-auto > nul | ||
sc start WSearch > nul | ||
|
||
%___settings% /unhide cortana-windowssearch | ||
|
||
echo Updating policy... ^(this might take a moment^) | ||
gpupdate > nul | ||
) | ||
|
||
if "%~1"=="/stop" ( | ||
echo Stopping the indexer... | ||
|
||
%___settings% /hide cortana-windowssearch | ||
|
||
rem Kill the search index Control Panel pane | ||
powershell -NoP -NonI -C "Stop-Process -Id (gcim Win32_Process | ? { $_.CommandLine -match 'srchadmin.dll' }).ProcessId -Force" | ||
|
||
sc config WSearch start=disabled > nul | ||
sc stop WSearch > nul 2>&1 | ||
) | ||
|
||
exit /b | ||
|
||
|
||
|
||
:help | ||
echo You must use one (not in combination) | ||
echo ------------------------------------- | ||
echo /include [full folder path] | ||
echo /exclude [full folder path] | ||
echo /cleanpolicies | ||
echo /start | ||
echo /stop | ||
exit /b | ||
|
||
|
||
:addIndexPath | ||
echo Configuring indexer path... | ||
set policy=DefaultIndexedPaths | ||
if "%~1"=="/exclude" set policy=DefaultExcludedPaths | ||
|
||
set "searchPath1=%~2" | ||
set "searchPath=file:///%searchPath1%\*" | ||
reg add "HKLM\Software\Policies\Microsoft\Windows\Windows Search\%policy%" /v "%searchPath%" /t REG_SZ /d "%searchPath%" /f > nul | ||
reg add "HKLM\Software\Microsoft\Windows Search\CurrentPolicies\%policy%" /v "%searchPath%" /t REG_SZ /d "%searchPath%" /f > nul | ||
exit /b | ||
|
||
|
||
:cleanPolicies | ||
for %%a in ( | ||
"HKLM\Software\Policies\Microsoft\Windows\Windows Search\DefaultExcludedPaths" | ||
"HKLM\Software\Policies\Microsoft\Windows\Windows Search\DefaultIndexedPaths" | ||
"HKLM\Software\Microsoft\Windows Search\CurrentPolicies\DefaultExcludedPaths" | ||
"HKLM\Software\Microsoft\Windows Search\CurrentPolicies\DefaultIndexedPaths" | ||
) do ( | ||
reg delete %%a /f > nul 2>&1 | ||
reg add %%a /f > nul 2>&1 | ||
) | ||
exit /b |