Skip to content

Commit

Permalink
feat: restructure env variables/localexpansion in batch scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyueta committed Oct 7, 2023
1 parent fbf61cb commit 7d4350e
Show file tree
Hide file tree
Showing 71 changed files with 123 additions and 189 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

if "%~1"=="/silent" goto main

Expand Down Expand Up @@ -36,7 +35,7 @@ call setSvc.cmd BthPan 4 > nul 2>&1
:: Disable Bluetooth devices
call %windir%\AtlasModules\Scripts\toggleDev.cmd -Silent '*Bluetooth*'

attrib +h "!APPDATA!\Microsoft\Windows\SendTo\Bluetooth File Transfer.LNK"
attrib +h "%APPDATA%\Microsoft\Windows\SendTo\Bluetooth File Transfer.LNK"

:: https://learn.microsoft.com/en-us/windows/client-management/mdm/policy-csp-connectivity
reg add "HKLM\SOFTWARE\Microsoft\PolicyManager\default\Connectivity\AllowBluetooth" /v "value" /t REG_DWORD /d "0" /f > nul
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down Expand Up @@ -37,8 +36,8 @@ call toggleDev.cmd -Silent -Enable '*Bluetooth*'
reg add "HKLM\SOFTWARE\Microsoft\PolicyManager\default\Connectivity\AllowBluetooth" /v "value" /t REG_DWORD /d "2" /f > nul

choice /c:yn /n /m "Would you like to enable the 'Bluetooth File Transfer' Send To context menu entry? [Y/N] "
if !errorlevel! == 1 attrib -h "!APPDATA!\Microsoft\Windows\SendTo\Bluetooth File Transfer.LNK"
if !errorlevel! == 2 attrib +h "!APPDATA!\Microsoft\Windows\SendTo\Bluetooth File Transfer.LNK"
if %errorlevel% == 1 attrib -h "%APPDATA%\Microsoft\Windows\SendTo\Bluetooth File Transfer.LNK"
if %errorlevel% == 2 attrib +h "%APPDATA%\Microsoft\Windows\SendTo\Bluetooth File Transfer.LNK"

echo Finished, please reboot your device for changes to apply.
pause
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

if "%~1"=="/silent" goto main

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

if "%~1"=="/silent" goto main

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

:: Check if hyper threading is enabled
for /f "tokens=2 delims==" %%a in ('wmic cpu get NumberOfCores /value') do set PHYSICAL_CORES=%%a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

powercfg /setacvalueindex scheme_current sub_processor 5d76a2ca-e8c0-402f-a133-2158492d58ad 0
powercfg /setactive scheme_current
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

if "%~1"=="/setup" goto main

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

if "%~1"=="/setup" goto main

Expand All @@ -11,9 +10,9 @@ whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
:: Detect if user uses laptop device or personal computer
for /f "delims=:{}" %%a in ('wmic path Win32_SystemEnclosure get ChassisTypes ^| findstr [0-9]') do set "CHASSIS=%%a"
set "DEVICE_TYPE=PC"
for %%a in (8 9 10 11 12 13 14 18 21 30 31 32) do if "!CHASSIS!" == "%%a" (set "DEVICE_TYPE=LAPTOP")
for %%a in (8 9 10 11 12 13 14 18 21 30 31 32) do if "%CHASSIS%" == "%%a" (set "DEVICE_TYPE=LAPTOP")

if "!DEVICE_TYPE!"=="LAPTOP" (
if "%DEVICE_TYPE%"=="LAPTOP" (
echo WARNING: You are on a laptop, disabling power saving features will cause faster battery drainage and increased heat output.
echo If you use your laptop on battery, certain power saving features will enable, but not all.
echo It's NOT recommended to disable power saving on laptops in general.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

if "%~1"=="/silent" goto main

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

if "%~1"=="/silent" goto main

Expand All @@ -8,8 +7,8 @@ whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
exit /b
)

if exist "!windir!\SystemApps\Microsoft.Windows.Search_cw5n1h2txyewy\SearchApp.exe" goto existS
if exist "!windir!\SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\StartMenuExperienceHost.exe" goto existS
if exist "%windir%\SystemApps\Microsoft.Windows.Search_cw5n1h2txyewy\SearchApp.exe" goto existS
if exist "%windir%\SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\StartMenuExperienceHost.exe" goto existS

:existS
if exist "%ProgramFiles%\Open-Shell" goto main
Expand All @@ -19,27 +18,27 @@ pause

:main
set /P c="This will disable SearchApp and StartMenuExperienceHost, are you sure you want to continue [Y/N]? "
if /I "!c!" == "Y" goto continSS
if /I "!c!" == "N" exit /b
if /I "!c!" == "" echo No option selected - launch the script again. & pause & exit /b 1
if /I "%c%" == "Y" goto continSS
if /I "%c%" == "N" exit /b
if /I "%c%" == "" echo No option selected - launch the script again. & pause & exit /b 1

:continSS
cd !windir!\SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy
cd %windir%\SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy

taskkill /f /im StartMenuExperienceHost* > nul 2>&1
ren StartMenuExperienceHost.exe StartMenuExperienceHost.exee > nul 2>&1

:: Loop if it fails to rename the first time
if exist "!windir!\SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\StartMenuExperienceHost.exe" goto restartStart
if exist "%windir%\SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\StartMenuExperienceHost.exe" goto restartStart

:restartSearch
cd !windir!\SystemApps\Microsoft.Windows.Search_cw5n1h2txyewy
cd %windir%\SystemApps\Microsoft.Windows.Search_cw5n1h2txyewy

taskkill /f /im SearchApp* > nul 2>&1
ren SearchApp.exe SearchApp.exee > nul 2>&1

:: Loop if it fails to rename the first time
if exist "!windir!\SystemApps\Microsoft.Windows.Search_cw5n1h2txyewy\SearchApp.exe" goto restartSearch
if exist "%windir%\SystemApps\Microsoft.Windows.Search_cw5n1h2txyewy\SearchApp.exe" goto restartSearch

:: Search icon
reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "SearchboxTaskbarMode" /t REG_DWORD /d "0" /f > nul
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
exit /b
)

:: Rename start menu
cd !windir!\SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy
cd %windir%\SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy
ren StartMenuExperienceHost.exee StartMenuExperienceHost.exe

:: Rename search
cd !windir!\SystemApps\Microsoft.Windows.Search_cw5n1h2txyewy
cd %windir%\SystemApps\Microsoft.Windows.Search_cw5n1h2txyewy
ren SearchApp.exee SearchApp.exe

:: Search icon
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@echo off
setlocal EnableDelayedExpansion

fltmc >nul 2>&1 || (
fltmc > nul 2>&1 || (
echo Administrator privileges are required.
PowerShell Start -Verb RunAs '%0' 2> nul || (
echo You must run this script as admin.
Expand All @@ -11,7 +10,7 @@ fltmc >nul 2>&1 || (
)

ping -n 1 -4 www.example.com | find "time=" > nul 2>&1
if !errorlevel! == 1 (
if %errorlevel% == 1 (
echo You must have an internet connection to use this script.
pause
exit /b 1
Expand All @@ -23,14 +22,14 @@ where winget > nul 2>&1 || (
exit /b 1
)

if exist "!windir!\SystemApps\Microsoft.Windows.Search_cw5n1h2txyewy\SearchApp.exe" goto existOS
if exist "!windir!\SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\StartMenuExperienceHost.exe" goto existOS
if exist "%windir%\SystemApps\Microsoft.Windows.Search_cw5n1h2txyewy\SearchApp.exe" goto existOS
if exist "%windir%\SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\StartMenuExperienceHost.exe" goto existOS
goto skipRM

:existOS
cls & set /P c="It appears search and start are installed, would you like to disable them also? [Y/N]? "
if /I "!c!" == "Y" goto rmSSOS
if /I "!c!" == "N" goto skipRM
if /I "%c%" == "Y" goto rmSSOS
if /I "%c%" == "N" goto skipRM

:rmSSOS
call "%windir%\AtlasDesktop\3. Configuration\Start Menu\Disable Start Menu and Search.cmd" /silent
Expand All @@ -40,21 +39,21 @@ echo]

:: Download and install Open-Shell
winget install -e --id Open-Shell.Open-Shell-Menu -h --accept-source-agreements --accept-package-agreements --force > nul
if !errorlevel! NEQ 0 (
if %errorlevel% NEQ 0 (
echo eror: Open-Shell installation failed.
pause
exit /b 1
)

:: Download Fluent Metro theme
for /f "delims=" %%a in ('PowerShell "(Invoke-RestMethod -Uri "https://api.github.com/repos/bonzibudd/Fluent-Metro/releases/latest").assets.browser_download_url"') do (
curl -L --output !TEMP!\skin.zip %%a
curl -L --output %TEMP%\skin.zip %%a
)

PowerShell -NoP -C "Expand-Archive '!TEMP!\skin.zip' -DestinationPath '$env:ProgramFiles\Open-Shell\Skins'"
PowerShell -NoP -C "Expand-Archive '%TEMP%\skin.zip' -DestinationPath '$env:ProgramFiles\Open-Shell\Skins'"

del /f /q !TEMP!\Open-Shell.exe > nul 2>&1
del /f /q !TEMP!\skin.zip > nul 2>&1
del /f /q %TEMP%\Open-Shell.exe > nul 2>&1
del /f /q %TEMP%\skin.zip > nul 2>&1

taskkill /f /im explorer.exe > nul 2>&1
start explorer.exe
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand Down Expand Up @@ -27,12 +26,12 @@ for %%a in ("%items:;=" "%") do (
if "%%~a" == "Documents" (set documents=true)
if "%%~a" == "Removable Drives" (set removableDrives=true)
)
if "!bluetooth!" == "true" (attrib +h "!APPDATA!\Microsoft\Windows\SendTo\Bluetooth File Transfer.LNK") else (attrib -h "!APPDATA!\Microsoft\Windows\SendTo\Bluetooth File Transfer.LNK")
if "!zipfolder!" == "true" (attrib +h "!APPDATA!\Microsoft\Windows\SendTo\Compressed (zipped) Folder.ZFSendToTarget") else (attrib -h "!APPDATA!\Microsoft\Windows\SendTo\Compressed (zipped) Folder.ZFSendToTarget")
if "!desktop!" == "true" (attrib +h "!APPDATA!\Microsoft\Windows\SendTo\Desktop (create shortcut).DeskLink") else (attrib -h "!APPDATA!\Microsoft\Windows\SendTo\Desktop (create shortcut).DeskLink")
if "!mail!" == "true" (attrib +h "!APPDATA!\Microsoft\Windows\SendTo\Mail Recipient.MAPIMail") else (attrib -h "!APPDATA!\Microsoft\Windows\SendTo\Mail Recipient.MAPIMail")
if "!documents!" == "true" (attrib +h "!APPDATA!\Microsoft\Windows\SendTo\Documents.mydocs") else (attrib -h "!APPDATA!\Microsoft\Windows\SendTo\Documents.mydocs")
if "!removableDrive!" == "true" (
if "%bluetooth%" == "true" (attrib +h "%APPDATA%\Microsoft\Windows\SendTo\Bluetooth File Transfer.LNK") else (attrib -h "%APPDATA%\Microsoft\Windows\SendTo\Bluetooth File Transfer.LNK")
if "%zipfolder%" == "true" (attrib +h "%APPDATA%\Microsoft\Windows\SendTo\Compressed (zipped) Folder.ZFSendToTarget") else (attrib -h "%APPDATA%\Microsoft\Windows\SendTo\Compressed (zipped) Folder.ZFSendToTarget")
if "%desktop%" == "true" (attrib +h "%APPDATA%\Microsoft\Windows\SendTo\Desktop (create shortcut).DeskLink") else (attrib -h "%APPDATA%\Microsoft\Windows\SendTo\Desktop (create shortcut).DeskLink")
if "%mail%" == "true" (attrib +h "%APPDATA%\Microsoft\Windows\SendTo\Mail Recipient.MAPIMail") else (attrib -h "%APPDATA%\Microsoft\Windows\SendTo\Mail Recipient.MAPIMail")
if "%documents%" == "true" (attrib +h "%APPDATA%\Microsoft\Windows\SendTo\Documents.mydocs") else (attrib -h "%APPDATA%\Microsoft\Windows\SendTo\Documents.mydocs")
if "%removableDrive%" == "true" (
reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v "NoDrivesInSendToMenu" /t REG_DWORD /d "1" /f > nul 2>&1
) else (
reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v "NoDrivesInSendToMenu" /f > nul 2>&1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand All @@ -13,7 +12,7 @@ echo [1] Disable the boot logo
echo [2] Enable the boot logo (default)
echo]
choice /c 12 /n /m "Type 1 or 2: "
if !errorlevel! == 1 (
if %errorlevel% == 1 (
goto disable
) else (
goto enable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand All @@ -16,7 +15,7 @@ echo [1] Disable boot messages
echo [2] Enable boot messages (default)
echo]
choice /c 12 /n /m "Type 1 or 2: "
if !errorlevel! == 1 (
if %errorlevel% == 1 (
goto disable
) else (
goto enable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand All @@ -16,7 +15,7 @@ echo [1] Disable the new boot menu (default)
echo [2] Enable the new boot menu
echo]
choice /c 12 /n /m "Type 1 or 2: "
if !errorlevel! == 1 (
if %errorlevel% == 1 (
goto disable
) else (
goto enable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@echo off
setlocal EnableDelayedExpansion

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" %*
Expand All @@ -12,7 +11,7 @@ echo [1] Disable the spinning animation
echo [2] Enable the spinning animation (default)
echo]
choice /c 12 /n /m "Type 1 or 2: "
if !errorlevel! == 1 (
if %errorlevel% == 1 (
goto disable
) else (
goto enable
Expand Down
Loading

0 comments on commit 7d4350e

Please sign in to comment.