Skip to content

Instantly share code, notes, and snippets.

@lenicyl
Last active November 16, 2021 12:59
Show Gist options
  • Save lenicyl/ef0fee9cbce6a73619e6c561585755cc to your computer and use it in GitHub Desktop.
Save lenicyl/ef0fee9cbce6a73619e6c561585755cc to your computer and use it in GitHub Desktop.
Installer Script

WIP

Script for personal use so dont run unless u want ur pc to be bloated to the brim

How do i fork this to work for my programs ?

  1. Install scoop and winget (and maybe github cli)
  2. search if app is available in scoop or winget
  3. edit the script accordingly
  4. Use your brain for programs not in package managers
  5. ???
  6. Profit and flex

Acknowledgements

Jakob Bindslet : for the Powershell cli menu script
hapylestat : For a modified version of the above

$AddOwnership = "https://www.tenforums.com/attachments/tutorials/314254d1610376708-add-take-ownership-context-menu-windows-10-a-add_shift-right-click_take_ownership_to_context_menu.reg"
. .\Write-Menu.ps1
Write-Host "Checking if the script is running with elevated permission ..."
# Checking for evevated permissions
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
[Security.Principal.WindowsBuiltInRole] "Administrator"))
{
Write-Host "This script needs to be run as an administrator, please run this script with elevated permissions and continue" -ForegroundColor Red
Break
}
else
{
Write-Host "Successful !!!`nThe script is running as an administrator`n " -ForegroundColor Green
$choice = "Yes", "No"
$selection = Menu $choice "Do you have winget installed ?"
switch ($selection) {
0 { Write-Host "Very cool" }
1 { Write-Host "Bruh"
exit }
Default {}
}
Write-Host "Installing prerequisites :`n" -ForegroundColor Cyan
Write-Host "Installing Scoop package manager...`n" -ForegroundColor Cyan
$selection = Menu $choice "Do you want to install scoop and its programs to a custom directory ?"
switch ($selection) {
0 {
$env:SCOOP = Read-Host "`nEnter the path you want to install scoop to..."
[environment]::setEnvironmentVariable('SCOOP',$env:SCOOP,'User')
iwr -useb get.scoop.sh | iex
}
1 { iwr -useb get.scoop.sh | iex }
Default {}
}
# Installing other prereq
Write-Host "Installing git..." -ForegroundColor Cyan
scoop install git
Write-Host "Installing Github Cli..." -ForegroundColor Cyan
scoop install gh
Write-Host "Installing Programs...`n" -ForegroundColor Cyan
Write-Host "Installing essential utilities...`n" -ForegroundColor Cyan
scoop bucket add extras
scoop install lockhunter 7zip bulk-crap-uninstaller everything
# Adding "Take Ownership" to Context Menu
Invoke-WebRequest -uri $AddOwnership -outfile "$env:TEMP/TakeOwnershipContextMenu.reg"
cd $env:TEMP
.\TakeOwnershipContextMenu.reg
Write-Host "Installing Utilities`n"
scoop install keepassxc motrix sharex wiztree ueli winaero-tweaker obsidian
Write-Host "Installing Customization`n" -ForegroundColor Cyan
scoop install taskbarx
# Dev
Write-Host "Installing Development stuff`n" -ForegroundColor Cyan
scoop install neofetch vscodium atom
Write-Host "Installing Games and launchers"
scoop bucket add games
scoop install multimc playnite discord
}
function moveCursor{ param($position)
$host.UI.RawUI.CursorPosition = $position
}
# Hide cursor
[System.Console]::CursorVisible = $false
function RedrawMenuItems{
param ([array]$menuItems, $oldMenuPos=0, $menuPosition=0, $currPos)
# +1 comes from leading new line in the menu
$menuLen = $menuItems.Count + 1
$fcolor = $host.UI.RawUI.ForegroundColor
$bcolor = $host.UI.RawUI.BackgroundColor
$menuOldPos = New-Object System.Management.Automation.Host.Coordinates(0, ($currPos.Y - ($menuLen - $oldMenuPos)))
$menuNewPos = New-Object System.Management.Automation.Host.Coordinates(0, ($currPos.Y - ($menuLen - $menuPosition)))
moveCursor $menuOldPos
Write-Host "`t" -NoNewLine
Write-Host "$oldMenuPos. $($menuItems[$oldMenuPos])" -fore $fcolor -back $bcolor -NoNewLine
moveCursor $menuNewPos
Write-Host "`t" -NoNewLine
Write-Host "$menuPosition. $($menuItems[$menuPosition])" -fore $bcolor -back $fcolor -NoNewLine
moveCursor $currPos
}
function DrawMenu { param ([array]$menuItems, $menuPosition, $menuTitel)
$fcolor = $host.UI.RawUI.ForegroundColor
$bcolor = $host.UI.RawUI.BackgroundColor
$menuwidth = $menuTitel.length + 4
Write-Host "`t" -NoNewLine; Write-Host ("=" * $menuwidth) -fore $fcolor -back $bcolor
Write-Host "`t" -NoNewLine; Write-Host " $menuTitel " -fore $fcolor -back $bcolor
Write-Host "`t" -NoNewLine; Write-Host ("=" * $menuwidth) -fore $fcolor -back $bcolor
Write-Host ""
for ($i = 0; $i -le $menuItems.length;$i++) {
Write-Host "`t" -NoNewLine
if ($i -eq $menuPosition) {
Write-Host "$i. $($menuItems[$i])" -fore $bcolor -back $fcolor -NoNewline
Write-Host "" -fore $fcolor -back $bcolor
} else {
if ($($menuItems[$i])) {
Write-Host "$i. $($menuItems[$i])" -fore $fcolor -back $bcolor
}
}
}
# leading new line
Write-Host ""
}
function Menu { param ([array]$menuItems, $menuTitel = "MENU")
$vkeycode = 0
$pos = 0
$oldPos = 0
DrawMenu $menuItems $pos $menuTitel
$currPos=$host.UI.RawUI.CursorPosition
While ($vkeycode -ne 13) {
$press = $host.ui.rawui.readkey("NoEcho,IncludeKeyDown")
$vkeycode = $press.virtualkeycode
Write-host "$($press.character)" -NoNewLine
$oldPos=$pos;
If ($vkeycode -eq 38) {$pos--}
If ($vkeycode -eq 40) {$pos++}
if ($pos -lt 0) {$pos = 0}
if ($pos -ge $menuItems.length) {$pos = $menuItems.length -1}
RedrawMenuItems $menuItems $oldPos $pos $currPos
}
Write-Output $pos
[System.Console]::CursorVisible = $true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment