Last active
August 19, 2021 17:47
-
-
Save spddl/55dbd23287c0e2bda7b3f9880826282a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference = 'SilentlyContinue' | |
Set-ExecutionPolicy -ExecutionPolicy Unrestricted | |
function generate_checkbox { | |
param( | |
[string]$checkboxText, | |
[string]$package, | |
[int]$newLocation | |
) | |
$checkbox = new-object System.Windows.Forms.checkbox | |
$checkbox.Location = new-object System.Drawing.Size(30, $newLocation) | |
$checkbox.Size = new-object System.Drawing.Size(250, 18) | |
$checkbox.Text = $checkboxText | |
$checkbox.Name = $package | |
$checkbox | |
} | |
[int] $separate = 30 | |
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | |
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") | |
# Set the size of your form | |
$Form = New-Object System.Windows.Forms.Form | |
# $Form.width = 320 | |
# $Form.height = 610 | |
# $Form.height = 1 | |
$Form.Text = "Install Software" # Titlebar | |
# label | |
$Label = New-Object System.Windows.Forms.label | |
$Label.Location = New-Object System.Drawing.Size(7, 10) | |
$Label.Size = New-Object System.Drawing.Size(130, 15) | |
$Label.BackColor = "Transparent" | |
$Label.Text = "Install Software:" | |
$Form.Controls.Add($Label) | |
$lastPos = 40 | |
# https://community.chocolatey.org/packages/msiafterburner | |
$Form.Controls.Add((generate_checkbox "MSI Afterburner" "msiafterburner" $lastPos)) | |
$lastPos += $separate | |
# https://community.chocolatey.org/packages/GoogleChrome | |
$Form.Controls.Add((generate_checkbox "Google Chrome" "googlechrome" $lastPos)) | |
$lastPos += $separate | |
# https://community.chocolatey.org/packages/Firefox | |
$Form.Controls.Add((generate_checkbox "Firefox" "firefox" $lastPos)) | |
$lastPos += $separate | |
# https://community.chocolatey.org/packages/amd-ryzen-chipset | |
$Form.Controls.Add((generate_checkbox "AMD Ryzen Chipset Drivers" "amd-ryzen-chipset" $lastPos)) | |
$lastPos += $separate | |
# https://community.chocolatey.org/packages/nvidia-display-driver | |
$Form.Controls.Add((generate_checkbox "NVidia Display Driver" "nvidia-display-driver" $lastPos)) | |
$lastPos += $separate | |
# https://community.chocolatey.org/packages?q=open+shell | |
$Form.Controls.Add((generate_checkbox "Open-Shell" "open-shell" $lastPos)) | |
$lastPos += $separate | |
# https://community.chocolatey.org/packages?q=7zip | |
$Form.Controls.Add((generate_checkbox "7-Zip" "7zip" $lastPos)) | |
$lastPos += $separate | |
# https://community.chocolatey.org/packages/vlc | |
$Form.Controls.Add((generate_checkbox "VLC media player" "vlc" $lastPos)) | |
$lastPos += $separate | |
# https://community.chocolatey.org/packages/foobar2000 | |
$Form.Controls.Add((generate_checkbox "foobar2000" "foobar2000" $lastPos)) | |
$lastPos += $separate | |
# https://community.chocolatey.org/packages/obs-studio | |
$Form.Controls.Add((generate_checkbox "OBS Studio" "obs-studio" $lastPos)) | |
$lastPos += $separate | |
# https://community.chocolatey.org/packages/samsung-nvme-driver | |
$Form.Controls.Add((generate_checkbox "samsung-nvme-driver" "samsung-nvme-driver" $lastPos)) | |
$lastPos += $separate | |
# https://community.chocolatey.org/packages?q=autoruns | |
$Form.Controls.Add((generate_checkbox "Autoruns" "autoruns" $lastPos)) | |
$lastPos += $separate | |
# https://community.chocolatey.org/packages?q=discord | |
$Form.Controls.Add((generate_checkbox "Discord" "discord" $lastPos)) | |
$lastPos += $separate | |
# https://community.chocolatey.org/packages?q=Visual+C%2B%2B ?? | |
# https://community.chocolatey.org/packages?q=NVIDIA+Profile+Inspector | |
$Form.Controls.Add((generate_checkbox "Nvidia Profile Inspector" "nvidia-profile-inspector" $lastPos)) | |
$lastPos += $separate | |
# https://community.chocolatey.org/packages?q=NVIDIA+Profile+Inspector | |
$Form.Controls.Add((generate_checkbox "CPU-Z" "cpu-z" $lastPos)) | |
$lastPos += $separate | |
# https://community.chocolatey.org/packages?q=NVIDIA+Profile+Inspector | |
$Form.Controls.Add((generate_checkbox "Notepad++" "notepadplusplus.install" $lastPos)) | |
$lastPos += $separate | |
$Form.height = $lastPos + 90 | |
$Form.width = 320 | |
$lastPos += 10 | |
$InstallButton = new-object System.Windows.Forms.Button | |
$InstallButton.Location = new-object System.Drawing.Size(20, $lastPos) | |
$InstallButton.Size = new-object System.Drawing.Size(80, 26) | |
$InstallButton.Text = "Install" | |
$InstallButton.Add_Click( { | |
$installPackages = [System.Collections.ArrayList]::new() | |
$form.Controls | Where-Object { $_ -is [System.Windows.Forms.Checkbox] } | ForEach-Object { | |
if ($_.Checked) { | |
$installPackages.Add($_.Name) | |
} | |
} | |
if (-not (Test-Path env:ChocolateyInstall)) { | |
Set-ExecutionPolicy Bypass -Scope Process -Force | |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 | |
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) | |
refreshenv | |
} | |
if ($data.count -ne 0) { | |
Start-Process -FilePath "choco" -Verb RunAs -ArgumentList "install $($installPackages -join ' ') -y" | |
} | |
$Form.Close() | |
}) | |
$form.Controls.Add($InstallButton) | |
$UpdateButton = new-object System.Windows.Forms.Button | |
$UpdateButton.Location = new-object System.Drawing.Size(110, $lastPos) | |
$UpdateButton.Size = new-object System.Drawing.Size(80, 26) | |
$UpdateButton.Text = "Update" | |
$UpdateButton.Add_Click( { | |
Start-Process -FilePath "choco" -Verb RunAs -ArgumentList "upgrade all" | |
}) | |
$form.Controls.Add($UpdateButton) | |
$TaskButton = new-object System.Windows.Forms.Button | |
$TaskButton.Location = new-object System.Drawing.Size(200, $lastPos) | |
$TaskButton.Size = new-object System.Drawing.Size(80, 26) | |
$TaskButton.Text = "Create Task" | |
$TaskButton.Add_Click( { | |
$action = New-ScheduledTaskAction -Execute 'choco' -Argument 'upgrade all' | |
$trigger = New-ScheduledTaskTrigger -AtLogon | |
$principal = New-ScheduledTaskPrincipal -UserID "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest | |
Register-ScheduledTask -Action $action -Trigger $trigger -Principal $principal -TaskName "Update chocolatey packages" -Description "Update chocolatey packages - KirbyOS" | |
[System.Windows.Forms.MessageBox]::Show("Done", "Task created", 0) | |
}) | |
$form.Controls.Add($TaskButton) | |
# Activate the form | |
$Form.Add_Shown( { $Form.Activate() }) | |
[void] $Form.ShowDialog() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment