Skip to content

Commit

Permalink
Win11Debloat now manually checks if git is installed (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphire committed May 23, 2024
1 parent 40b5cf4 commit 9401de8
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Get.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,25 @@ Write-Output "------------------------------------------------------------------

# Make sure winget is installed and is at least v1.4
if ((Get-AppxPackage -Name "*Microsoft.DesktopAppInstaller*") -and ((winget -v) -replace 'v','' -gt 1.4)) {
# Install git if it isn't already installed
Write-Output "> Installing git..."
winget install git.git --accept-package-agreements --accept-source-agreements --disable-interactivity --no-upgrade
# Check if git is installed. Install git if it isn't installed yet
try
{
git | Out-Null
}
catch [System.Management.Automation.CommandNotFoundException]
{
Write-Output "> Installing git..."
winget install git.git --accept-package-agreements --accept-source-agreements --disable-interactivity --no-upgrade

Write-Output ""
}

# Navigate to user temp directory
cd $env:TEMP

# Add default install location of git to path
$env:Path += ';C:\Program Files\Git\cmd'

This comment has been minimized.

Copy link
@lxl66566

lxl66566 May 24, 2024

How about moving this line to the catch block? (And I don't know if winget will deal with Path automaticly though.)

This comment has been minimized.

Copy link
@Raphire

Raphire May 24, 2024

Author Owner

Good catch! This definitely needs to be inside the catch block. I'll fix this in the next update.

WinGet will deal automatically with path, but the path variable in the current powershell session won't be updated. This way is a bit hacky, but it avoids the need to start a new powershell session.


Write-Output ""

# Download Win11Debloat from github
Write-Output "> Downloading Win11Debloat..."
git clone https://github.com/Raphire/Win11Debloat/
Expand All @@ -75,5 +82,5 @@ if ((Get-AppxPackage -Name "*Microsoft.DesktopAppInstaller*") -and ((winget -v)
Remove-Item -LiteralPath "Win11Debloat" -Force -Recurse
}
else {
Write-Error "Unable to start script, Winget is not installed or outdated."
Write-Error "Unable to start script, WinGet is not installed or outdated."
}

0 comments on commit 9401de8

Please sign in to comment.