confOS/windows11.bat
2024-08-21 19:14:47 +02:00

424 lines
18 KiB
Batchfile

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET "repo=https://git.mylloon.fr/Anri/confOS/raw/branch/main"
SET "local=%HOMEPATH%\Documents\Local"
MKDIR "!local!" 2>NUL
:: => NO-ADMIN RIGHTS <=
fltmc >NUL 2>&1 || (
ECHO Please wait until the administrator popup appears.
:: === Update winget to latest version ==
PowerShell -Command "" ^
"Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile winget.msixbundle;" ^
"Add-AppPackage -ForceApplicationShutdown .\winget.msixbundle;" ^
"del .\winget.msixbundle"
:: === Scripts from ./windows directory ==
PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/update.bat -OutFile '!local!\update.bat'"
PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/clean.bat -OutFile '!local!\ctmpf.bat'"
PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/installers/spotify.bat -OutFile '!local!\blockthespot.bat'"
PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/installers/vencord.bat -OutFile '!local!\vencord_installer.bat'"
PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/fix_nvidia_wsl.bat -OutFile '!local!\fix_nvidia_wsl.bat'"
PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/fix_mihoyo_shortcut.bat -OutFile '!local!\fix_mihoyo_shortcut.bat'"
PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/start_obs_as_shadowplay.bat -OutFile '%LOCALAPPDATA%\start_obs_as_shadowplay.bat'"
:: === Install Spotify ==
DEL "%APPDATA%\Spotify"
:: Use already downloaded script
ECHO Y| CMD /c "!local!\blockthespot.bat" yes
PowerShell -Command "Stop-Process -Name Spotify -ErrorAction SilentlyContinue"
:: Start as administrator
PowerShell Start -Verb RunAs "%0 noskipadmin" 2>NUL || (
EXIT 1
)
EXIT 0
)
:: => ADMIN RIGHTS <=
IF NOT "%1"=="noskipadmin" (
ECHO You have to run the script as normal user first.
PAUSE
EXIT 0
)
:: === Registery modifications ==
ECHO Registery entries...
:: Right click of Windows 10
:: REG ADD "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve
:: Disabling widgets
REG ADD "HKLM\Software\Policies\Microsoft\Dsh" /v AllowNewsAndInterests /t REG_DWORD /d 0 /f
:: Disabling hibernation (prevents computer to really shutdown)
REG ADD "HKLM\System\CurrentControlSet\Control\Session Manager\Power" /v HiberbootEnabled /t REG_DWORD /d 0 /f
powercfg /H off
:: Disabling the SysMain service (preload some apps in memory)
sc stop "SysMain" & sc config "SysMain" start=disabled
:: Added confirmation when trashing
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v ConfirmFileDelete /t REG_DWORD /d 1 /f
:: Don't create Zone.Identifier
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments" /v SaveZoneInformation /t REG_DWORD /d 1 /f
:: Disables memory integrity
:: see https://support.microsoft.com/en-us/windows/options-to-optimize-gaming-performance-in-windows-11-a255f612-2949-4373-a566-ff6f3f474613
REG ADD "HKLM\System\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" /v Enabled /t REG_DWORD /d 0 /f
:: Disables sticky keys
REG ADD "HKCU\Control Panel\Accessibility\StickyKeys" /v Flags /t REG_SZ /d 506 /f
:: Remove default shortcuts for changing input language and keyboard layout
:: WIN+Space still available
REG ADD "HKCU\Keyboard Layout\toggle" /v "Hotkey" /t REG_SZ /d 3 /f
REG ADD "HKCU\Keyboard Layout\toggle" /v "Language Hotkey" /t REG_SZ /d 3 /f
:: Disable Game Bar
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\GameDVR" /v AppCaptureEnabled /t REG_DWORD /d 0 /f
REG ADD "HKCU\System\GameConfigStore" /v GameDVR_Enabled /t REG_DWORD /d 0 /f
:: Edge tweaks
REG ADD "HKLM\Software\Policies\Microsoft\Edge" /v HubsSidebarEnabled /t REG_DWORD /d 0 /f
REG ADD "HKLM\Software\Policies\Microsoft\Edge" /v ShowRecommendationsEnabled /t REG_DWORD /d 0 /f
REG ADD "HKLM\Software\Policies\Microsoft\Edge" /v SpotlightExperiencesAndRecommendationsEnabled /t REG_DWORD /d 0 /f
:: Disable Windows Copilot
REG ADD "HKCU\Software\Policies\Microsoft\Windows\WindowsCopilot" /v TurnOffWindowsCopilot /t REG_DWORD /d 1 /f
:: Disable checkboxes in explorer
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v AutoCheckSelect /t REG_DWORD /d 0 /f
:: Disable web search in start menu
:: TODO: Need testing
:: REG ADD "HKCU\Software\Policies\Microsoft\Windows\Explorer" /v DisableSearchBoxSuggestions /t REG_DWORD /d 1 /f
:: Disable ad in file explorer
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v ShowSyncProviderNotifications /t REG_DWORD /d 0 /f
:: Disable ad in login screen
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v RotatingLockScreenOverlayEnabled /t REG_DWORD /d 0 /f
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v SubscribedContent-338387Enabled /t REG_DWORD /d 0 /f
:: Disable ad in settings and notifications
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v SubscribedContent-338393Enabled /t REG_DWORD /d 0 /f
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v SubscribedContent-353694Enabled /t REG_DWORD /d 0 /f
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v SubscribedContent-353696Enabled /t REG_DWORD /d 0 /f
:: Disable ad at boot
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement" /v ScoobeSystemSettingEnabled /t REG_DWORD /d 0 /f
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v SubscribedContent-310093Enabled /t REG_DWORD /d 0 /f
:: Disable targeted ad
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo" /v Enabled /t REG_DWORD /d 0 /f
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Privacy" /v TailoredExperiencesWithDiagnosticDataEnabled /t REG_DWORD /d 0 /f
:: Disable ad in start menu
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Start_IrisRecommendations /t REG_DWORD /d 0 /f
:: === Install optional features ==
PowerShell -Command "" ^
"Get-WindowsCapability -Online -Name 'App.WirelessDisplay.Connect*' | Add-WindowsCapability -Online"
:: === WinGet ==
:: Auto accept ToT
ECHO Y | winget list >NUL
SET "pmi=winget install --silent --exact"
:: C++ libraries
SET ^"cpp_libs=^
Microsoft.VCRedist.2005.x86 Microsoft.VCRedist.2005.x64 ^
Microsoft.VCRedist.2008.x86 Microsoft.VCRedist.2008.x64 ^
Microsoft.VCRedist.2010.x86 Microsoft.VCRedist.2010.x64 ^
Microsoft.VCRedist.2012.x86 Microsoft.VCRedist.2012.x64 ^
Microsoft.VCRedist.2013.x86 Microsoft.VCRedist.2013.x64 ^
Microsoft.VCRedist.2015+.x86 Microsoft.VCRedist.2015+.x64"
ECHO C++ libraries...
for %%i in (!cpp_libs!) do (
!pmi! %%i
)
:: .NET libraries
SET ^"net_libs=^
Microsoft.DotNet.DesktopRuntime.3_1 Microsoft.DotNet.SDK.3_1 ^
Microsoft.DotNet.DesktopRuntime.5 Microsoft.DotNet.SDK.5 ^
Microsoft.DotNet.DesktopRuntime.6 Microsoft.DotNet.SDK.6 ^
Microsoft.DotNet.DesktopRuntime.7 Microsoft.DotNet.SDK.7 ^
Microsoft.DotNet.DesktopRuntime.8 Microsoft.DotNet.SDK.8"
ECHO .NET libraries...
for %%i in (!net_libs!) do (
!pmi! %%i
)
:: Java dev kits
SET ^"java_jdk=^
Oracle.JavaRuntimeEnvironment EclipseAdoptium.Temurin.17.JDK ^
EclipseAdoptium.Temurin.21.JDK"
ECHO JDK...
for %%i in (!java_jdk!) do (
!pmi! %%i
)
:: Drivers
SET ^"drivers=^
Nvidia.CUDA"
ECHO Drivers...
for %%i in (!drivers!) do (
!pmi! %%i
)
:: Applications
SET ^"apps=^
Discord.Discord Spotify.Spotify Mozilla.Firefox M2Team.NanaZip GIMP.GIMP ^
voidtools.Everything.Lite VideoLAN.VLC Obsidian.Obsidian Parsec.Parsec ^
Microsoft.VisualStudioCode Bitwarden.Bitwarden sylikc.JPEGView ^
TheDocumentFoundation.LibreOffice Armin2208.WindowsAutoNightMode ^
OBSProject.OBSStudio Xournal++.Xournal++ Microsoft.PowerToys KDE.KDEConnect ^
OpenWhisperSystems.Signal TenacityTeam.Tenacity Microsoft.PowerShell"
ECHO Apps...
for %%i in (!apps!) do (
!pmi! %%i
)
:: Games related, temporary disable local for exclamation mark escaping
SETLOCAL DISABLEDELAYEDEXPANSION
SET ^"games=^
RiotGames.LeagueOfLegends.EUW RiotGames.Valorant.EU Valve.Steam ^
HeroicGamesLauncher.HeroicGamesLauncher PrismLauncher.PrismLauncher ^
Ryujinx.Ryujinx Peppy.Osu^^!"
SETLOCAL ENABLEDELAYEDEXPANSION
ECHO Games...
for %%i in (!games!) do (
!pmi! %%i
)
:: === Ryujinx shortcut ==
:: Installed from winget as a portable app
PowerShell -Command "" ^
"$WshShell = New-Object -comObject WScript.Shell;" ^
"$exe = (Get-ChildItem $env:LOCALAPPDATA\Microsoft\WinGet\Packages\Ryujinx.Ryujinx_Microsoft.Winget.*\publish\Ryujinx.exe).FullName;" ^
"$Shortcut = $WshShell.CreateShortcut('%APPDATA%\Microsoft\Windows\Start Menu\Programs\Ryujinx.lnk');" ^
"$Shortcut.TargetPath = $exe;" ^
"$Shortcut.Save()"
:: === Install WSL ==
ECHO WSL...
wsl --install --no-distribution
:: === Activate Windows ==
:: TODO: Fix command, see https://massgrave.dev/command_line_switches#uses-in-powershell-one-liner
:: PowerShell -Command "" ^
:: "& ([ScriptBlock]::Create((irm https://get.activated.win )))" ^
:: "/HWID"
:: === Modules for Windows Update ==
PowerShell -Command "Install-PackageProvider -Name NuGet -Force"
PowerShell -Command "Install-Module -Name PSWindowsUpdate -Force"
:: === Geek Uninstaller ==
PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/installers/geek.bat -OutFile '%TEMP%\geek.bat'"
CMD /c "%TEMP%\geek.bat" yes
:: === LosslessCut ==
PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/installers/losslesscut.bat -OutFile '%TEMP%\losslesscut.bat'"
CMD /c "%TEMP%\losslesscut.bat" yes
:: === DSR ==
PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/installers/dsr.bat -OutFile '%TEMP%\dsr.bat'"
CMD /c "%TEMP%\dsr.bat" yes
:: === Vencord ==
:: Use already downloaded script
CMD /c "!local!\vencord_installer.bat" yes
:: === OpenTabletDriver ==
ECHO OpenTabletDriver...
PowerShell -Command "" ^
"$archive = '%TEMP%\OpenTabletDriver.win-x64.zip';" ^
"Invoke-WebRequest -Uri https://github.com/OpenTabletDriver/OpenTabletDriver/releases/latest/download/OpenTabletDriver.win-x64.zip -OutFile $archive;" ^
"Expand-Archive -Path $archive -DestinationPath '%ProgramFiles%\OpenTabletDriver' -Force;" ^
"$WshShell = New-Object -comObject WScript.Shell;" ^
"$Shortcut = $WshShell.CreateShortcut('%APPDATA%\Microsoft\Windows\Start Menu\Programs\OpenTabletDriver.lnk');" ^
"$Shortcut.TargetPath = '%ProgramFiles%\OpenTabletDriver\OpenTabletDriver.UX.Wpf.exe';" ^
"$Shortcut.WorkingDirectory = '%ProgramFiles%\OpenTabletDriver';" ^
"$Shortcut.Save();" ^
"Remove-Item -Force $archive"
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTabletDriver" /f /v DisplayName /t REG_SZ /d "OpenTabletDriver"
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTabletDriver" /f /v InstallLocation /t REG_SZ /d "%ProgramFiles%\OpenTabletDriver"
:: WindowsInk for OpenTabletDriver
ECHO WindowsInk support for OpenTabletDriver...
PowerShell -Command "Invoke-WebRequest -Uri https://github.com/X9VoiD/vmulti-bin/releases/download/v1.0/VMulti.Driver.zip -OutFile '%TEMP%\VMulti-Driver.zip'"
PowerShell -Command "Expand-Archive -Path '%TEMP%\VMulti-Driver.zip' -DestinationPath '%TEMP%\VMulti-Driver' -Force"
CALL "%TEMP%\VMulti-Driver\install_hiddriver.bat"
PowerShell -Command "Invoke-WebRequest -Uri https://github.com/X9VoiD/VoiDPlugins/releases/latest/download/WindowsInk.zip -OutFile '%TEMP%\WindowsInk.zip'"
PowerShell -Command "Expand-Archive -Path '%TEMP%\WindowsInk.zip' -DestinationPath '%LOCALAPPDATA%\OpenTabletDriver\Plugins\Windows Ink' -Force"
:: Presets of OpenTabletDriver
ECHO Downloading OpenTabletDriver presets...
PowerShell -Command "Invoke-WebRequest -Uri !repo!/opentabletdriver/vertical-main.json -OutFile '%LOCALAPPDATA%\OpenTabletDriver\Presets\vertical-main.json'"
PowerShell -Command "Invoke-WebRequest -Uri !repo!/opentabletdriver/vertical-second.json -OutFile '%LOCALAPPDATA%\OpenTabletDriver\Presets\vertical-second.json'"
:: Settings of OpenTabletDriver, using 'vertical-main.json' as default settings
ECHO Setting up OpenTabletDriver...
XCOPY "%LOCALAPPDATA%\OpenTabletDriver\Presets\vertical-main.json" "%LOCALAPPDATA%\OpenTabletDriver\settings.json" /-I /Y
:: Start minimized at startup
PowerShell -Command "" ^
"$WshShell = New-Object -comObject WScript.Shell;" ^
"$Shortcut = $WshShell.CreateShortcut('%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\OpenTabletDriver.lnk');" ^
"$Shortcut.TargetPath = '%ProgramFiles%\OpenTabletDriver\OpenTabletDriver.UX.Wpf.exe';" ^
"$Shortcut.WorkingDirectory = '%ProgramFiles%\OpenTabletDriver';" ^
"$Shortcut.WindowStyle = 7;" ^
"$Shortcut.Save()"
:: === NOWT ==
PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/installers/nowt.bat -OutFile '%TEMP%\nowt.bat'"
CMD /c "%TEMP%\nowt.bat" yes
:: === Deceive ==
PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/installers/deceive.bat -OutFile '%TEMP%\deceive.bat'"
CMD /c "%TEMP%\deceive.bat" yes
:: === Xournal++ ==
:: TODO: Winget report an incorrect hash on installation,
:: that's why we're installing it manually
:: ECHO Xournal++...
:: PowerShell -Command "" ^
:: "$repo = 'xournalpp/xournalpp';" ^
:: "$releases = \"https://api.github.com/repos/$repo/releases\";" ^
:: "$tag = (Invoke-WebRequest $releases | ConvertFrom-Json)[1].tag_name;" ^
:: "$file = \"xournalpp-$($tag.substring(1))-windows.zip\";" ^
:: "$link = \"https://github.com/$repo/releases/download/$tag/$file\";" ^
:: "$archive = 'xournalpp.zip';" ^
:: "$outfile = Join-Path -Path $env:TEMP -ChildPath $archive;" ^
:: "Invoke-WebRequest -Uri $link -OutFile $outfile;" ^
:: "cd $env:TEMP;" ^
:: "Expand-Archive -Path $archive -DestinationPath $env:TEMP -Force;" ^
:: "$exe = $env:TEMP + '\' + $file.Substring(0, $file.Length - 3) + 'exe';" ^
:: "Start-Process $exe /S;" ^
:: "Remove-Item -Force $outfile;" ^
:: "Remove-Item -Force $exe"
:: === Minecraft ==
:: Rename shortcut for Minecraft
RENAME "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Prism Launcher.lnk" Minecraft.lnk
:: === Cubiomes viewer ==
PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/installers/cubiomesviewer.bat -OutFile '%TEMP%\cubiomesviewer.bat'"
CMD /c "%TEMP%\cubiomesviewer.bat" yes
:: === Firefox configuration ==
:: Open and close Firefox for the first time, generating a profile
"%ProgramFiles%\Mozilla Firefox\firefox.exe"
TIMEOUT 5
TASKKILL /im firefox.exe /F
ECHO Firefox configuration...
FOR /F "usebackq delims=" %%i IN (`dir /B /S "%APPDATA%\Mozilla\Firefox\Profiles\*.default-release"`) DO SET "vbc=%%i"
PowerShell -Command "Invoke-WebRequest -Uri !repo!/.mozilla/firefox/user.js -OutFile '!vbc!\user.js'"
:: Download addons settings in "Download" folder
PowerShell -Command "Invoke-WebRequest -Uri !repo!/.mozilla/firefox/extensions/SponsorBlockConfig.json -OutFile '%HOMEPATH%\Downloads\SponsorBlockConfig.json'"
PowerShell -Command "Invoke-WebRequest -Uri !repo!/.mozilla/firefox/extensions/auto-tab-discard-preferences.json -OutFile '%HOMEPATH%\Downloads\auto-tab-discard-preferences.json'"
ECHO Configuration files for Firefox Addons are in the download folder (%HOMEPATH%\Downloads).
:: === WindowsAutoNightMode ==
ECHO WindowsAutoNightMode configuration...
MKDIR "%APPDATA%\AutoDarkMode" 2>NUL
PowerShell -Command "Invoke-WebRequest -Uri !repo!/.config/WindowsAutoNightMode/config.yaml -OutFile '%APPDATA%\AutoDarkMode\config.yaml'"
"%LOCALAPPDATA%\Programs\AutoDarkMode\adm-app\AutoDarkModeApp.exe"
:: === OBS ==
:: Create directories for configurations
MKDIR "%ProgramFiles%\obs-studio\config\obs-studio\basic\profiles\ReplayBuffer" 2>NUL
MKDIR "%ProgramFiles%\obs-studio\config\obs-studio\basic\scenes" 2>NUL
:: Download configuration
PowerShell -Command "Invoke-WebRequest -Uri !repo!/.config/obs/global.ini -OutFile '%ProgramFiles%\obs-studio\config\obs-studio\global.ini'"
PowerShell -Command "Invoke-WebRequest -Uri !repo!/.config/obs/basic/profiles/ReplayBuffer/basic.ini -OutFile '%ProgramFiles%\obs-studio\config\obs-studio\basic\profiles\ReplayBuffer\basic.ini'"
PowerShell -Command "Invoke-WebRequest -Uri !repo!/.config/obs/basic/profiles/ReplayBuffer/recordEncoder.json -OutFile '%ProgramFiles%\obs-studio\config\obs-studio\basic\profiles\ReplayBuffer\recordEncoder.json'"
PowerShell -Command "Invoke-WebRequest -Uri !repo!/.config/obs/basic/scenes/ReplayBuffer.json -OutFile '%ProgramFiles%\obs-studio\config\obs-studio\basic\scenes\ReplayBuffer.json'"
:: OBS Scripts
PowerShell -Command "" ^
"$archive = '%TEMP%\obs-replay-folders.zip';" ^
"Invoke-WebRequest -Uri https://github.com/Mylloon/obs-replay-folders/releases/latest/download/obs-replay-folders.zip -OutFile $archive;" ^
"Expand-Archive -Path $archive -DestinationPath '%ProgramFiles%\obs-studio\config' -Force;" ^
"Remove-Item -Force $archive"
:: Setup the autostart of shadowplay
SCHTASKS /Create /RU "%USERNAME%" /SC ONLOGON /TN "OBS Shadowplay" ^
/TR "'%LOCALAPPDATA%\start_obs_as_shadowplay.bat'" ^
/F /RL HIGHEST
:: Allow system to go in sleep mode when OBS is running
POWERCFG /REQUESTSOVERRIDE PROCESS obs64.exe DISPLAY SYSTEM AWAYMODE
ECHO About OBS, you may need to adjust the screen ID by opening the OBS app
ECHO in the systray as it may be not the same as the one presaved.
:: === miHoYo Games launcher ==
PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/installers/collapse.bat -OutFile '%TEMP%\collapse.bat'"
CMD /c "%TEMP%\collapse.bat" yes
:: Fix games shortcut
CMD /c "!local!\fix_mihoyo_shortcut.bat" yes
:: === FiveM ==
PowerShell -Command "Invoke-WebRequest -Uri !repo!/windows/installers/fivem.bat -OutFile '%TEMP%\fivem.bat'"
CMD /c "%TEMP%\fivem.bat" yes
:: === DaVinci Resolve ==
ECHO Useful link to download the latest version of DaVinci Resolve:
ECHO https://www.blackmagicdesign.com/support/family/davinci-resolve-and-fusion
:: === Drivers notice ==
ECHO Installs drivers, for a list of drivers, use UserDiag https://userdiag.com/download
ECHO For NVidia, use NVC and DDU.
:: === End message ==
ECHO ""
ECHO Take a look at your Windows settings, after you've done all the updates available on your PC.
ECHO Lastly, restart the computer.
PAUSE
EXIT /B