Skip to content

Commit

Permalink
(LeDragoX#54) Use new method to install DesktopAppInstaller (Winget)
Browse files Browse the repository at this point in the history
- Install winget package with the Add-AppxProvisionedPackage command
- Fixes some console errors on backup-system.ps1
- Fixes disable News and Interest not finding the path
- Add tmp/*.xml file to .gitignore
  • Loading branch information
LeDragoX committed Aug 22, 2022
1 parent ca89bbf commit d3a96f2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
**/tmp/**/*.cer
**/tmp/**/*.exe
**/tmp/**/*.ttf
**/tmp/**/*.xml
**/tmp/Fonts/*

# Downloaded temporary files
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/backup-system.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function Backup-HostsFile() {
Push-Location "$PathToHostsFile"

If (!(Test-Path "$PathToHostsFile\Hosts_Backup")) {
Write-Status -Types "?", $TweakType -Status "Backup folder not found! Creating a new one..." -ForegroundColor Yellow -BackgroundColor Black
Write-Status -Types "?", $TweakType -Status "Backup folder not found! Creating a new one..." -Warning
mkdir -Path "$PathToHostsFile\Hosts_Backup"
}
Push-Location "Hosts_Backup"
Expand Down
14 changes: 11 additions & 3 deletions src/scripts/install-package-managers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function Install-WingetDependency() {
$AppName = Split-Path -Path $WingetDepOutput -Leaf

Try {
Write-Status -Types "@" -Status "Trying to install the App: $AppName"
Write-Status -Types "@" -Status "Trying to install the App: $AppName" -Warning
$InstallPackageCommand = { Add-AppxPackage -Path $WingetDepOutput }
Invoke-Expression "$InstallPackageCommand"
If ($LASTEXITCODE) { Throw "Couldn't install automatically" }
Expand All @@ -97,19 +97,27 @@ function Main() {
{
Install-WingetDependency
$WingetOutput = Get-APIFile -URI "https://api.github.com/repos/microsoft/winget-cli/releases/latest" -ObjectProperty "assets" -FileNameLike "*.msixbundle" -PropertyValue "browser_download_url" -OutputFile "Microsoft.DesktopAppInstaller.msixbundle"
$WingetLicenseOutput = Get-APIFile -URI "https://api.github.com/repos/microsoft/winget-cli/releases/latest" -ObjectProperty "assets" -FileNameLike "*License*.xml" -PropertyValue "browser_download_url" -OutputFile "WingetLicense.xml"
$AppName = Split-Path -Path $WingetOutput -Leaf

Try {
Write-Status -Types "@" -Status "Trying to install the App: $AppName"
$InstallPackageCommand = { Add-AppxPackage -Path $WingetOutput }
# Method from: https://github.com/microsoft/winget-cli/blob/master/doc/troubleshooting/README.md#machine-wide-provisioning
Write-Status -Types "@" -Status "Trying to install the App (w/ license): $AppName" -Warning
$InstallPackageCommand = { Add-AppxProvisionedPackage -Online -PackagePath $WingetOutput -LicensePath $WingetLicenseOutput | Out-Null }
Invoke-Expression "$InstallPackageCommand"
If ($LASTEXITCODE) { Throw "Couldn't install automatically" }

Write-Status -Types "@" -Status "Trying to install the App (w/out license): $AppName" -Warning
$OldInstallPackageCommand = { Add-AppxPackage -Path $WingetOutput }
Invoke-Expression "$OldInstallPackageCommand"
If ($LASTEXITCODE) { Throw "Couldn't install automatically" }
} Catch {
Write-Status -Types "@" -Status "Couldn't install '$AppName' automatically, trying to install the App manually..." -Warning
Start-Process "ms-windows-store://pdp/?ProductId=9NBLGGH4NNS1" -Wait # GUI App installer can't install itself
}

Remove-Item -Path $WingetOutput
Remove-Item -Path $WingetLicenseOutput
}
Time = "12:00"
UpdateScriptBlock =
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/other-scripts/new-system-color.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Import-Module -DisableNameChecking $PSScriptRoot\..\..\lib\"title-templates.psm1"

Function New-SystemColor() {
function New-SystemColor() {
$ColorHistory = Get-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\History\Colors"
$HexColor = "{0:X6}" -f (Get-Random -Maximum 0xFFFFFF)
$HexColorBGR = "$($HexColor[4..5] + $HexColor[2..3] + $HexColor[0..1])".Split(" ") -join ""
Expand Down
3 changes: 3 additions & 0 deletions src/scripts/personal-tweaks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ function Register-PersonalTweaksList() {
Set-ItemProperty -Path "$PathToCUNewsAndInterest" -Name "ShellFeedsTaskbarOpenOnHover" -Type DWord -Value $Zero

Write-Status -Types $EnableStatus[0].Symbol, $TweakType -Status "$($EnableStatus[0].Status) 'News and Interest' from taskbar..."
If (!(Test-Path "$PathToLMPoliciesNewsAndInterest")) {
New-Item -Path "$PathToLMPoliciesNewsAndInterest" -Force | Out-Null
}
# [@] (0 = Disable, 1 = Enable)
Set-ItemProperty -Path "$PathToLMPoliciesNewsAndInterest" -Name "EnableFeeds" -Type DWord -Value $Zero

Expand Down

0 comments on commit d3a96f2

Please sign in to comment.