Skip to content

Instantly share code, notes, and snippets.

@fishd72
Created December 12, 2023 15:48
Show Gist options
  • Save fishd72/81af8abf320117e3605193e95beb6017 to your computer and use it in GitHub Desktop.
Save fishd72/81af8abf320117e3605193e95beb6017 to your computer and use it in GitHub Desktop.
Performs UI customisation on Windows 10 to improve VM performance
$color = 0x0063B1
$CSharpScript = @"
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;
public class SolidWallpaper
{
public const int SetDesktopWallpaper = 20;
public const int UpdateIniFile = 0x01;
public const int SendWinIniChange = 0x02;
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fWinIni);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern bool SetSysColors(int cElements, int[] lpaElements, uint[] lpaRgbValues);
public static void SetWallpaper(uint color) {
// clear current wallpaper and update ini
SystemParametersInfo(SetDesktopWallpaper, 0, "", UpdateIniFile | SendWinIniChange);
// set solid color
int[] lpaElements = { 1 };
uint[] lpaRgbValues = { color };
SetSysColors(1, lpaElements, lpaRgbValues);
// save to registry
int rgb = (int)color;
RegistryKey key = Registry.CurrentUser.OpenSubKey("Control Panel\\Colors", true);
key.SetValue(@"Background", string.Format("{0} {1} {2}", (rgb >> 16) & 0xff, (rgb >> 8) & 0xff, (rgb >> 0) & 0xff));
}
}
"@
add-type -typedefinition $CSharpScript
[SolidWallpaper]::SetWallpaper($color)
# Disable themed login screen
Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\System -Name 'DisableLogonBackgroundImage' -Type Dword -Value 1
# Set interface for best performance
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects -Name 'VisualFXSetting' -Type 'Dword' -Value 2
# Disable Windows Search box
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name 'ShowTaskViewButton' -Type 'DWord' -Value 0
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name 'SearchboxTaskbarMode' -Type 'DWord' -Value 0
# Disable news and interests
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds" -Name "ShellFeedsTaskbarViewMode" -Value 2
# Restart Explorer
#Get-Process -Name Explorer | Stop-Process -Force
#Start-Sleep -Seconds 2
# Restart themes
Restart-Service -Name Themes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment