Skip to content

Instantly share code, notes, and snippets.

@sweshelo
Created January 14, 2022 12:55
Show Gist options
  • Save sweshelo/f4e0c30d121101682354db4cf9dede17 to your computer and use it in GitHub Desktop.
Save sweshelo/f4e0c30d121101682354db4cf9dede17 to your computer and use it in GitHub Desktop.
Windows アプリケーションインストール
$BaseList = @(
@{
Name="Scoop"
Alias="scoop"
Source="web"
Command="iwr -useb get.scoop.sh | iex"
},
@{
Name="VisualStudio Code"
Alias="code"
Source="winget"
Command="winget install Microsoft.visualstudiocode"
},
@{
Name="PowerShell (V 7.x.x)"
Alias="pwsh"
Source="winget"
Command="winget install pwsh"
},
@{
Name="Windows Terminal"
Alias="wt"
Source="winget"
Command="winget install microsoft.windowsterminal"
},
@{
Name="Google Chrome"
Alias="chrome"
Source="winget"
Command="winget install google.chrome"
},
@{
Name="Git"
Alias="git"
Source="scoop"
Command="scoop install git"
},
@{
Name="Sass"
Alias="sass"
Source="scoop"
Command="scoop install sass"
},
@{
Name="Neo VIM"
Alias="nvim"
Source="scoop"
Command="scoop install neovim"
},
@{
Name="sudo"
Alias="sudo"
Source="scoop"
Command="scoop install sudo"
}
);
#====
$list = @();
$HasScoop = $true;
$NeedScoop = $false;
$BaseList | %{
$App=$_;
$ErrorActionPreference = 'Continue';
$chk = gcm $App.Alias -ErrorAction SilentlyContinue
if ( $? -eq $false ){
$list += @($App)
if($App.Name -eq "scoop"){
$HasScoop = $false;
}
if($App.Source -eq "scoop"){
$NeedScoop = $true;
}
}
}
if ($list.length -eq 0){
echo "全てインストール済みです。";
exit 0;
}
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$Form = New-Object System.Windows.Forms.Form;
$Form.Size = "300, 200";
$Form.Text = "Application Selection"
$CB = New-Object System.Windows.Forms.CheckedListBox;
$CB.Location = "10,10";
$CB.Size = "260,100";
$CB.Items.AddRange($list.Name);
$CB.ClearSelected();
$Form.Controls.Add($CB);
$Button = New-Object System.Windows.Forms.Button;
$Button.Location = "110, 110";
$Button.Size = "80, 20";
$Button.Text = "Install";
$Button.DialogResult = "OK";
$Form.AcceptButton = $Button;
$Form.Controls.Add($Button);
$Form.Add_Shown({$Form.Activate()})
if ($Form.ShowDialog() -ne "OK") {exit 1;}
# Scoop
if($HasScoop -eq $false -and $NeedScoop -eq $true){
$CB.CheckedItems += @("Scoop")
}
# Install
$CB.CheckedItems | %{
$item = $_;
($BaseList | ?{ $_.Name -eq $item }).Command | iex;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment