You are on page 1of 2

# Define the URL for the Chrome installer

$chromeUrl = "https://dl.google.com/chrome/install/latest/chrome_installer.exe"

# Define the URL of the image


$imageUrl = "https://i0.wp.com/saportareport.com/wp-content/uploads/2022/08/google-
night-nime-featured-photo-scaled.jpeg"

# Define the paths


$chromeInstallerPath = "$env:TEMP\ChromeInstaller.exe"
$imagePath = "$env:TEMP\wallpaper.jpg"
$logPath = "$env:USERPROFILE\Desktop\InstallationLog.txt"

# Function to write to log file


function Write-Log {
param([string]$Message)
Add-content -Path $logPath -Value $Message
}

# Initialize log file


Write-Log "Starting Google Chrome installation process..."

# Download Chrome installer


Write-Log "Downloading Google Chrome installer from $chromeUrl..."
Invoke-WebRequest -Uri $chromeUrl -OutFile $chromeInstallerPath

# Download the image


Write-Log "Downloading wallpaper image from $imageUrl..."
Invoke-WebRequest -Uri $imageUrl -OutFile $imagePath

# Install Chrome silently


Write-Log "Installing Google Chrome silently..."
Start-Process $chromeInstallerPath -ArgumentList "/silent", "/install" -NoNewWindow
-Wait

# Set the desktop wallpaper


Write-Log "Setting desktop wallpaper..."
Add-Type -TypeDefinition @"
using System;
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);
public const int SPI_SETDESKWALLPAPER = 20;
public const int SPIF_UPDATEINIFILE = 0x01;
public const int SPIF_SENDCHANGE = 0x02;

public static void SetDesktopWallpaper(string path) {


SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, path, SPIF_UPDATEINIFILE |
SPIF_SENDCHANGE);
}
}
"@

# Set the wallpaper


[Wallpaper]::SetDesktopWallpaper($imagePath)

# Clean up
Write-Log "Cleaning up..."
Remove-Item $chromeInstallerPath
Remove-Item $imagePath

# Finish log
Write-Log "Installation process completed."

# Move log file to desktop


Write-Log "Enjoy using Chrome for the next 24 hours. Uninstalling before the end of
the 24 hours is a violation of the rules and Hurts my feelings."
Move-Item -Path $logPath -Destination "$env:USERPROFILE\Desktop\
InstallationLog.txt"

You might also like