Skip to content

Commit

Permalink
wingetを使用するように変更・二つ目のパッケージリストを追加・やることを選択できるように
Browse files Browse the repository at this point in the history
  • Loading branch information
Deryck2000 committed Jan 15, 2025
1 parent f9665ed commit d07d5f8
Showing 3 changed files with 199 additions and 36 deletions.
6 changes: 6 additions & 0 deletions sources/packages-ex.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Discord.Discord
Valve.Steam
Flow-Launcher.Flow-Launcher
PrismLauncher.PrismLauncher
Bitwarden.Bitwarden
RustemMussabekov.Raindrop
22 changes: 11 additions & 11 deletions sources/packages.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
git.install
pwsh
powertoys
tabby
path-copy-copy
flow-launcher
sublimetext4
eartrumpet
opera-gx
discord.install
steam
Git.Git
GitHub.GitHubDesktop
OpenJS.NodeJS
Microsoft.PowerShell
Microsoft.PowerToys
Eugeny.Tabby
CLechasseur.PathCopyCopy
SublimeHQ.SublimeText.4
File-New-Project.EarTrumpet
Opera.OperaGX
CubeSoft.CubeICE
207 changes: 182 additions & 25 deletions sources/setup.ps1
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ Write-Host " \____/\____\\_/\_\/_/ \____/\_|\_\\____/\____/\____/\____/ " -For
Write-Host "�f�f�I�`������PC�Z�b�g�A�b�v�ɂ悤�����I"
Write-Host "Version 2.0"
Start-Sleep -Seconds 1
Write-Host " "
Write-Host "�Ǘ��Ҍ����Ŏ��s����Ă��邩�`�F�b�N���܂�..."

# �Ǘ��Ҍ������`�F�b�N����֐�
@@ -23,18 +24,39 @@ if (-not (Test-Admin)) {
}

Write-Host "�Ǘ��Ҍ����ŃX�N���v�g�����s����Ă��܂��B�Z�b�g�A�b�v�𑱍s���܂��B" -ForegroundColor Green

Write-Host " "
Start-Sleep -Seconds 1

# ���[�U�[�t�H���_�Ɉړ�
Set-Location -Path $env:USERPROFILE

function SelectJob {
while ($true) {
$input = Read-Host "�Z�b�g�A�b�v��I������������"

if ($input -eq "1" -or $input -eq "2" -or $input -eq "3") {
return $input
} else {
Write-Host "�����ȓ��͂ł��B������x��蒼���Ă��������B" -ForegroundColor Red
}
}
}







# ------------------------------------------------------------------------------
# ���W�X�g���ҏW
# ------------------------------------------------------------------------------

function Job1 {
Write-Host "���W�X�g����ҏW���܂�..."

Start-Sleep -Seconds 1
Write-Host " "

# �G�N�X�v���[���Ŋg���q��\��
Write-Host "���W�X�g����ҏW:�G�N�X�v���[���Ŋg���q��\��..."
@@ -63,84 +85,183 @@ Set-ItemProperty -Path 'HKCU:\Control Panel\Mouse' -Name 'MouseSpeed' -Value 0
Set-ItemProperty -Path 'HKCU:\Control Panel\Mouse' -Name 'MouseThreshold1' -Value 0
Set-ItemProperty -Path 'HKCU:\Control Panel\Mouse' -Name 'MouseThreshold2' -Value 0

Write-Host "���W�X�g���̕ҏW���������܂����B"
Write-Host " "
Write-Host "���W�X�g���̕ҏW���������܂����B" -ForegroundColor Green
Start-Sleep -Seconds 1

# ------------------------------------------------------------------------------
# DNS�ݒ�̕ύX
# ------------------------------------------------------------------------------

Write-Host " "
Write-Host "�p�u���b�NDNS��Google�̂��̂ɕύX���܂��B"
Start-Sleep -Seconds 1

$interfaceIndex = (Get-NetIPInterface -AddressFamily IPv4).InterfaceIndex
Set-DnsClientServerAddress -InterfaceIndex $interfaceIndex -ServerAddresses 8.8.8.8

Write-Host "�p�u���b�NDNS��ύX���܂����B"
Write-Host "�p�u���b�NDNS��ύX���܂����B" -ForegroundColor Green
Start-Sleep -Seconds 1

Selecter


}
# ------------------------------------------------------------------------------
# Chocolatey���C���X�g�[��
# �p�b�P�[�W�̃C���X�g�[��
# ------------------------------------------------------------------------------
Write-Host "Chocolatey���C���X�g�[�����܂�..."

function Job2 {
Write-Host " "
Write-Host "WinGet���C���X�g�[������Ă��邩�`�F�b�N���܂�..."

# WinGet ���C���X�g�[������Ă��邩���`�F�b�N����
function Test-WinGet {
$chocoPath = (Get-Command winget -ErrorAction SilentlyContinue).Path
return -not [string]::IsNullOrEmpty($chocoPath)
}

if (Test-WinGet) {

Write-Host "WinGet�̓C���X�g�[������Ă��܂��B" -ForegroundColor Green

}else{

Write-Host "WinGet���C���X�g�[�����܂��B"
Start-Sleep -Seconds 1
$progressPreference = 'silentlyContinue'
Write-Host "Installing WinGet PowerShell module from PSGallery..."
Install-PackageProvider -Name NuGet -Force | Out-Null
Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null
Write-Host "Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet..."
Repair-WinGetPackageManager
Write-Host "WinGet���C���X�g�[�����܂����B" -ForegroundColor Green
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
Write-Host "�‹��ϐ����ēǂݍ��݂��܂����B" -ForegroundColor Green
}

Start-Sleep -Seconds 1
Write-Host " "

Write-Host "WinGet���g�p���ăp�b�P�[�W���C���X�g�[�����܂��B"
Start-Sleep -Seconds 1

# ���s�������ʂ̃X�N���v�g�̃p�X��ݒ肷��
$packageTxt = Join-Path -Path $PSScriptRoot -ChildPath "packages.txt"

# �C���X�g�[������p�b�P�[�W�̃��X�g���t�@�C������ǂݍ���
$packageList = Get-Content -Path $packageTxt

# �C���X�g�[���Ɏ��s�����p�b�P�[�W��ێ�����z��
$failedInstalls = @()

Write-Host " "
Write-Host "�C���X�g�[������p�b�P�[�W���X�g:"
$packageList | ForEach-Object { Write-Host $_ }
Start-Sleep -Seconds 1

Write-Host " "
Write-Host "�C���X�g�[�����J�n���܂��B"
Start-Sleep -Seconds 1

foreach ($software in $packageList) {
Write-Host "$software ���C���X�g�[�����܂�..."
winget install -e --id $software
if ($LASTEXITCODE -ne 0) {
Write-Host "$software �̃C���X�g�[���Ɏ��s���܂����B" -ForegroundColor Red
$failedInstalls += $software
Start-Sleep -Seconds 1
Write-Host " "
} else {
Write-Host "$software �𐳏�ɃC���X�g�[�����܂����B" -ForegroundColor Green
Start-Sleep -Seconds 1
Write-Host " "
}
}

Start-Sleep -Seconds 1

# Chocolatey�̃C���X�g�[��
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# ���s�����p�b�P�[�W���o��
if ($failedInstalls.Count -gt 0) {
Write-Host "�����̃p�b�P�[�W�̃C���X�g�[���Ɏ��s���܂���:" -ForegroundColor Red
$failedInstalls | ForEach-Object { Write-Host $_ }
} else {
Write-Host "���ׂẴp�b�P�[�W�𐳏�ɃC���X�g�[�����܂����B" -ForegroundColor Green
}


Write-Host "Chocolatey���C���X�g�[�����܂����B"
Start-Sleep -Seconds 1
Selecter

$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
}

Write-Host "Chocolatey���C���X�g�[������Ă��邩�`�F�b�N���܂�..."

# Chocolatey ���C���X�g�[������Ă��邩���`�F�b�N����
function Test-Chocolatey {
$chocoPath = (Get-Command choco -ErrorAction SilentlyContinue).Path
function Job3 {

Write-Host " "
Write-Host "WinGet���C���X�g�[������Ă��邩�`�F�b�N���܂�..."

# WinGet ���C���X�g�[������Ă��邩���`�F�b�N����
function Test-WinGet {
$chocoPath = (Get-Command winget -ErrorAction SilentlyContinue).Path
return -not [string]::IsNullOrEmpty($chocoPath)
}

if (-not (Test-Chocolatey)) {
Write-Host "Chocolatey���C���X�g�[������Ă��܂���B�Z�b�g�A�b�v���I�����܂��B" -ForegroundColor Red
pause
exit
if (Test-WinGet) {

Write-Host "WinGet�̓C���X�g�[������Ă��܂��B" -ForegroundColor Green

}else{

Write-Host "WinGet���C���X�g�[�����܂��B"
Start-Sleep -Seconds 1
$progressPreference = 'silentlyContinue'
Write-Host "Installing WinGet PowerShell module from PSGallery..."
Install-PackageProvider -Name NuGet -Force | Out-Null
Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null
Write-Host "Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet..."
Repair-WinGetPackageManager
Write-Host "WinGet���C���X�g�[�����܂����B" -ForegroundColor Green
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
Write-Host "�‹��ϐ����ēǂݍ��݂��܂����B" -ForegroundColor Green
}

Write-Host "Chocolatey�̓C���X�g�[������Ă��܂��B�Z�b�g�A�b�v�𑱍s���܂��B" -ForegroundColor Green
Start-Sleep -Seconds 1
Write-Host " "

Write-Host "Chocolatey���g�p���ăp�b�P�[�W���C���X�g�[�����܂��B"
Write-Host "WinGet���g�p���ăp�b�P�[�W���C���X�g�[�����܂��B"
Start-Sleep -Seconds 1

# ���s�������ʂ̃X�N���v�g�̃p�X��ݒ肷��
$packageTxt = Join-Path -Path $PSScriptRoot -ChildPath "packages.txt"
$packageTxt = Join-Path -Path $PSScriptRoot -ChildPath "packages-ex.txt"

# �C���X�g�[������p�b�P�[�W�̃��X�g���t�@�C������ǂݍ���
$packageList = Get-Content -Path $packageTxt

# �C���X�g�[���Ɏ��s�����p�b�P�[�W��ێ�����z��
$failedInstalls = @()

Write-Host " "
Write-Host "�C���X�g�[������p�b�P�[�W���X�g:"
$packageList | ForEach-Object { Write-Host $_ }
Start-Sleep -Seconds 1

Write-Host " "
Write-Host "�C���X�g�[�����J�n���܂��B"
Start-Sleep -Seconds 1

foreach ($software in $packageList) {
Write-Host "$software ���C���X�g�[�����܂�..."
choco install $software -y
winget install -e --id $software
if ($LASTEXITCODE -ne 0) {
Write-Host "$software �̃C���X�g�[���Ɏ��s���܂����B" -ForegroundColor Red
$failedInstalls += $software
Start-Sleep -Seconds 1
Write-Host " "
} else {
Write-Host "$software �𐳏�ɃC���X�g�[�����܂����B" -ForegroundColor Green
Start-Sleep -Seconds 1
Write-Host " "
}
}

@@ -151,7 +272,43 @@ if ($failedInstalls.Count -gt 0) {
Write-Host "�����̃p�b�P�[�W�̃C���X�g�[���Ɏ��s���܂���:" -ForegroundColor Red
$failedInstalls | ForEach-Object { Write-Host $_ }
} else {
Write-Host "���ׂẴp�b�P�[�W�𐳏�ɃC���X�g�[�����܂����B" -ForegroundColor Green
Write-Host "���ׂẴG�N�X�g���E�p�b�P�[�W�𐳏�ɃC���X�g�[�����܂����B" -ForegroundColor Green
}


Start-Sleep -Seconds 1
Selecter

}


# ------------------------------------------------------------------------------
# �I��
# ------------------------------------------------------------------------------

function Selecter{

Write-Host " "
Write-Host "------------------------------"
Write-Host " "
Write-Host "���s������̂�I�����Ă��������B"
Write-Host " "
Write-Host "1 : ���W�X�g���ҏW�E�p�u���b�NDNS�̕ύX"
Write-Host "2 : �p�b�P�[�W�̃C���X�g�[��"
Write-Host "3 : �G�N�X�g���E�p�b�P�[�W�̃C���X�g�[��"
Write-Host " "
$userInput = SelectJob

if ($userInput -eq "1") {
Write-Host "���W�X�g���ҏW�E�p�u���b�NDNS�̕ύX �����s���܂��B"
Job1
} elseif ($userInput -eq "2") {
Write-Host "�p�b�P�[�W�̃C���X�g�[�� �����s���܂��B"
Job2
} elseif ($userInput -eq "3") {
Write-Host "3 : �G�N�X�g���E�p�b�P�[�W�̃C���X�g�[�� �����s���܂��B"
Job3
}
}

pause
Selecter

0 comments on commit d07d5f8

Please sign in to comment.