Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save haridhayal11/d1d78a4054cd621de12990de3df9dc9c to your computer and use it in GitHub Desktop.

Select an option

Save haridhayal11/d1d78a4054cd621de12990de3df9dc9c to your computer and use it in GitHub Desktop.
function Set-DarkTheme {
# Set Windows 10 to use dark theme for apps and system
$KeyPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"
$NameApps = "AppsUseLightTheme"
$NameSystem = "SystemUsesLightTheme"
$Value = 0 # 0 for dark mode, 1 for light mode
# Create the key if it doesn't exist
If (-Not (Test-Path $KeyPath)) {
New-Item -Path $KeyPath -Force | Out-Null
}
# Set the value to use dark mode for apps
Set-ItemProperty -Path $KeyPath -Name $NameApps -Value $Value
# Set the value to use dark mode for the system
Set-ItemProperty -Path $KeyPath -Name $NameSystem -Value $Value
# Restart Windows Explorer to apply changes
Stop-Process -Name explorer -Force
Start-Process explorer.exe
}
function Run-Executable {
param (
[string[]]$SubfolderNames,
[string]$FileName
)
# Define the path to the executable file
$DocumentsPath = [environment]::GetFolderPath("MyDocuments")
$FilePath = $DocumentsPath
# Construct the path using all subfolder names
foreach ($subfolder in $SubfolderNames) {
$FilePath = Join-Path -Path $FilePath -ChildPath $subfolder
}
$FileFullPath = Join-Path -Path $FilePath -ChildPath $FileName
# Run the executable file
Start-Process $FileFullPath
}
# Set the dark theme
Set-DarkTheme
# Run the first executable in a nested subfolder
# Run-Executable -SubfolderNames @("AutoHotkey") -FileName "shortcuts.exe"
# Run the second executable in another nested subfolder
Run-Executable -SubfolderNames @("Portable", "phyrox-portable") -FileName "phyrox-portable.exe"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment