Koulukone automaatio - db2ca277f8c41c61d424a8a313d40a72becc4e3e7e900d6f54ec227401a9479e

📅 2023-05-11T12:45:29.291Z
👁️ 157 katselukertaa
🔓 Julkinen


$path = "$HOME\wallpaper.jpg"

# Download wallpaper
echo "Downloading wallpaper"
Invoke-WebRequest -URI "https://images.unsplash.com/photo-1682687221006-b7fd60cf9dd0" -OutFile $path

# Set wallpaper
echo "Setting wallpaper"
$setwallpapersrc = @"
using System.Runtime.InteropServices;
public class Wallpaper
{
  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 fuWinIni);
  public static void SetWallpaper(string path)
  { SystemParametersInfo(SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange); }
}
"@
Add-Type -TypeDefinition $setwallpapersrc
[Wallpaper]::SetWallpaper($path)

echo "Hiding desktop icons"
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideIcons" -Value 1
Get-Process "explorer"| Stop-Process

$source = @"
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]  
public static extern bool SystemParametersInfo(  
                 uint uiAction,  
                 uint uiParam,  
                 uint pvParam,  
                 uint fWinIni);  
"@

$apicall = Add-Type -MemberDefinition $source -Name WinAPICall -Namespace SystemParamInfo -PassThru
$apicall::SystemParametersInfo(0x009F, 4294967294, $null, 1) | Out-Null