-
Notifications
You must be signed in to change notification settings - Fork 0
/
winget-autoinstaller.ps1
193 lines (183 loc) · 7.14 KB
/
winget-autoinstaller.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
Write-Host "Winget is not installed. Please install 'App Installer' from the Microsoft Store."
exit 1
}
Add-Type -AssemblyName System.Windows.Forms
# Create the main form
$form = New-Object System.Windows.Forms.Form
$form.Text = "Program Installer"
$form.Size = New-Object System.Drawing.Size(600, 500)
$form.StartPosition = "CenterScreen"
$form.FormBorderStyle = "FixedDialog"
$form.MaximizeBox = $false
# Create a label for instructions
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(20, 20)
$label.Size = New-Object System.Drawing.Size(360, 20)
$label.Text = "Select programs to install:"
$form.Controls.Add($label)
# Create a scrollable panel to hold the checked list box and headers
$panel = New-Object System.Windows.Forms.Panel
$panel.Location = New-Object System.Drawing.Point(20, 50)
$panel.Size = New-Object System.Drawing.Size(550, 350)
$panel.AutoScroll = $true
$form.Controls.Add($panel)
# Function to add a category header
function Add-CategoryHeader($panel, [string]$text, [ref]$yPos) {
$header = New-Object System.Windows.Forms.Label
$header.Text = $text
$header.Font = New-Object System.Drawing.Font("Arial", 10, [System.Drawing.FontStyle]::Bold)
$header.Location = New-Object System.Drawing.Point(0, $yPos.Value)
$header.Size = New-Object System.Drawing.Size(360, 20)
$panel.Controls.Add($header)
$yPos.Value += 20
}
# Function to add items to the checked list box
function Add-CheckedListBoxItems($panel, [hashtable]$items, [ref]$yPos) {
foreach ($friendlyName in $items.Keys) {
$checkbox = New-Object System.Windows.Forms.CheckBox
$checkbox.Text = $friendlyName
$checkbox.Tag = $items[$friendlyName]
$checkbox.Location = New-Object System.Drawing.Point(0, $yPos.Value)
$checkbox.Size = New-Object System.Drawing.Size(500, 20)
$panel.Controls.Add($checkbox)
$yPos.Value += 20
}
}
# Define the categories and their programs
$categories = @{
"Text Editors" = @{
"Atom" = "Github.Atom"
"Brackets" = "Adobe.Brackets"
"Gedit" = "Gnome.Gedit"
"GNU Emacs" = "GNU.Emacs"
"Kate" = "KDE.Kate"
"Nano" = "GNU.Nano"
"Neovim" = "Neovim.Neovim"
"NetBeans IDE" = "Apache.NetBeans"
"Notepad++" = "Notepad++.Notepad++"
"Vim" = "Vim.vim"
"Visual Studio Code" = "Microsoft.VisualStudioCode"
}
"Artwork Tools" = @{
"Blender" = "BlenderFoundation.Blender"
"GIMP" = "GIMP.GIMP"
"Inkscape" = "Inkscape.Inkscape"
"Krita" = "KDE.Krita"
"Paint.NET" = "dotPDN.PaintDotNet"
}
"Communication Apps" = @{
"Discord" = "Discord.Discord"
"Element" = "Element.Element"
"Hexchat" = "Hexchat.Hexchat"
"mIRC" = "mIRC.mIRC"
"Mozilla Thunderbird" = "Mozilla.Thunderbird"
"Pidgin" = "Pidgin.Pidgin"
"Quassel" = "Quassel.QuasselIRC"
"Slack" = "SlackTechnologies.Slack"
"Telegram" = "Telegram.TelegramDesktop"
}
"Web Browsers" = @{
"Arc" = "TheBrowserCompany.Arc"
"Brave" = "Brave.Brave"
"Google Chrome" = "Google.Chrome"
"K-Meleon" = "kmeleonbrowser.K-Meleon"
"LibreWolf" = "LibreWolf.LibreWolf"
"Mozilla Firefox" = "Mozilla.Firefox"
"Opera" = "Opera.Opera"
"Opera GX" = "Opera.OperaGX"
"Pale Moon" = "MoonchildProductions.PaleMoon"
"Qutebrowser" = "Qutebrowser.Qutebrowser"
"Thorium" = "Alex313031.Thorium"
"TOR Browser" = "TorProject.TorBrowser"
"Waterfox" = "Waterfox.Waterfox"
}
"Video Game Clients" = @{
"Bethesda Launcher" = "Bethesda.Launcher"
"EA Origin" = "ElectronicArts.Origin"
"Epic Games Launcher" = "EpicGames.EpicGamesLauncher"
"GOG Galaxy" = "GOG.Galaxy"
"Itch.io" = "ItchIo.Itch"
"Steam" = "Valve.Steam"
"Ubisoft Connect" = "Ubisoft.Connect"
}
"Development Tools" = @{
"7-Zip" = "7zip.7zip"
"Angry IP Scanner" = "angryziber.AngryIPScanner"
"balenaEtcher" = "Balena.Etcher"
"Docker" = "Docker.DockerDesktop"
"Docker Edge" = "Docker.DockerDesktopEdge"
"Git" = "git.git"
"GitHub Desktop" = "GitHub.GitHubDesktop"
"GNU Privacy Guard (GPG)" = "GnuPG.GnuPG"
"Neofetch" = "nepnep.neofetch-win"
"PuTTY" = "PuTTY.PuTTY"
"Python" = "Python.Python"
"Raspberry Pi Imager" = "RaspberryPiFoundation.RaspberryPiImager"
"Rustup" = "Rustlang.Rustup"
"VirtualBox" = "Oracle.VirtualBox"
"WinRAR" = "RARLab.WinRAR"
}
"Productivity Apps" = @{
"Adobe Acrobat" = "Adobe.Acrobat.Reader"
"Dropbox" = "Dropnox.Dropbox"
"Google Drive" = "Google.GoogleDrive"
"iCloud" = "Apple.iCloud"
"LibreOffice" = "TheDocumentFoundation.LibreOffice"
"Microsoft Office" = "Microsoft.Office"
"Okular" = "KDE.okular"
"OneDrive" = "Microsoft.Onedrive"
"OpenOffice" = "Apache.OpenOffice"
}
"Torrent Clients" = @{
"Deluge" = "DelugeTeam.Deluge"
"PicoTorrent" = "Picotorrent.Picotorrent"
"qBittorrent" = "qBittorrent.qBittorrent"
"Transmission" = "Transmission.Transmission"
"Tribler" = "Tribler.Tribler"
}
"Media Players" = @{
"Jellyfin Media Player" = "Jellyfin.JellyfinMediaPlayer"
"Spotify" = "Spotify.Spotify"
"Strawberry Music Player" = "StrawberryMusicPlayer.Strawberry"
"VLC Media Player" = "VideoLAN.VLC"
"Winamp" = "Winamp.Winamp"
"YouTube Music" = "Ytmdesktop.Ytmdesktop"
}
}
# Populate the panel with categories and items
$yPos = 0
foreach ($category in $categories.Keys) {
Add-CategoryHeader -panel $panel -text $category -yPos ([ref]$yPos)
Add-CheckedListBoxItems -panel $panel -items $categories[$category] -yPos ([ref]$yPos)
}
# Create an "Install" button
$buttonInstall = New-Object System.Windows.Forms.Button
$buttonInstall.Location = New-Object System.Drawing.Point(120, 420)
$buttonInstall.Size = New-Object System.Drawing.Size(160, 30)
$buttonInstall.Text = "Install Selected Programs"
$buttonInstall.Add_Click({
$buttonInstall.Enabled = $false
try {
# Install selected programs
foreach ($control in $panel.Controls) {
if ($control -is [System.Windows.Forms.CheckBox] -and $control.Checked) {
$program = $control.Tag
Write-Host "Installing $program ..."
winget install -e --id $program
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to install $program."
} else {
Write-Host "$program installed successfully."
}
}
}
} finally {
$buttonInstall.Enabled = $true
}
$form.Close()
})
$form.Controls.Add($buttonInstall)
# Show the form
$form.Add_Shown({ $form.Activate() })
[void] $form.ShowDialog()