Add background.cmd
This commit is contained in:
1 parent
33024a144d
commit
0ede448f44
1 file changed
+43
@@ -0,0 +1,43 @@
|
||||
# 2>NUL & @CLS & PUSHD "%~dp0" & "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -noLogo -noProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText('%~f0')|iex" & POPD & EXIT /B
|
||||
|
||||
# URL of the image
|
||||
$imageUrl = "https://git.hibbit.net/Huracan/wallpaper/raw/commit/33024a144d2d891fc55c5bcc3332fe0d88b6ffb6/huracan.jpg"
|
||||
|
||||
# Create temp directory if it doesn't exist
|
||||
$tempDir = "$env:TEMP\wallpaper"
|
||||
if (-not (Test-Path $tempDir)) {
|
||||
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
|
||||
}
|
||||
|
||||
# Download the image
|
||||
$wallpaperPath = "$tempDir\background.jpg"
|
||||
Write-Host "Downloading wallpaper..." -ForegroundColor Yellow
|
||||
try {
|
||||
Invoke-WebRequest -Uri $imageUrl -OutFile $wallpaperPath -TimeoutSec 60
|
||||
Write-Host "Download complete!" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Error "Failed to download wallpaper: $_"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Set the wallpaper
|
||||
try {
|
||||
$code = @'
|
||||
using System.Runtime.InteropServices;
|
||||
public class Wallpaper {
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
|
||||
}
|
||||
'@
|
||||
|
||||
Add-Type -TypeDefinition $code
|
||||
$SPI_SETDESKWALLPAPER = 0x0014
|
||||
$SPIF_UPDATEINIFILE = 0x01
|
||||
$SPIF_SENDCHANGE = 0x02
|
||||
|
||||
[Wallpaper]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $wallpaperPath, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE)
|
||||
Write-Host "Wallpaper set successfully!" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Error "Failed to set wallpaper: $_"
|
||||
exit 1
|
||||
}
|
||||
Reference in new issue
Block a user