Compare commits

..

13 Commits

Author SHA1 Message Date
Chris Titus Tech
f4d4bdad3c move prefer ipv4 to advanced 2024-12-09 12:08:27 -06:00
Chris Titus Tech
9d47514190 move prefer ipv4 to advanced 2024-12-09 12:07:56 -06:00
ChrisTitusTech
4fc34e44b3 Deploying to main from @ ChrisTitusTech/winutil@c33946bde2 🚀 2024-12-09 15:34:30 +00:00
Chris Titus
c33946bde2 tweaks remove all 2024-12-09 00:21:45 -06:00
ChrisTitusTech
4466720493 Deploying to main from @ ChrisTitusTech/winutil@1d0e3bfd5c 🚀 2024-12-08 15:33:04 +00:00
MyDrift
1d0e3bfd5c
[FEAT] TweakToggles logik overhaul (#3014)
* move logic to json template

- remove Invoke-WPFToggle.ps1
- generalize Get-WinUtilToggleStatus
- add bingsearch reg key for testing
- use Invoke-WinUtilTweaks for actions
- replace Add-Click with checked & unchecked to make undo work

* add reg params for toggles into tweaks.json

- add all reg keys to tweaks.json into existing toggle entry
- remove unneeded scripts

* fix HKU

- load HKU if needed (for tweaks & GetToggleStatus)
- remove unneeded Invoke-WinUtilNumLock
- has loaded HKU does not load/not stay loaded

* add a lot of error handling

* Bugfix: New-PSDrive seems to return the "hku" itself so weirdly gets prepended to the return value so the result becomes ("hku", $false). In powershell pretty much every variable that exists is interpreted as $true so the toggle for numlock got incorrectly checked

* globally fix HKU error & minimize console feedback

- fix HKU issue globally
- remove some console logs, change some others to write-debug

* update Explorerrefresh

- change Invoke-WinUtilExplorerRefresh to handle refresh and restart
- add restart logic to window snapping Flyout & Suggestions
- rename Invoke-WinUtilExplorerRefresh to Invoke-WinUtilExplorerUpdate

* add explorer restart where needed to take effect

add explorer restart logic for hidden files + Fileextension toggles

* fix missing theme change logic in darkmode toggle

* fix window snapping

- fix issue defining WindowArrangementActive as dword instead of string

* fix bing search

- switch bing search enabled/disabled values

* add a little bit of error handling

- add error handling for Get-WinUtilToggleStatus

---------

Co-authored-by: Marterich <47688561+Marterich@users.noreply.github.com>
2024-12-05 21:24:36 -06:00
Mr.k
83450aef7b
[UI/UX] Update the look & feel of the GUI (#2884)
* Add @CodingWonders to the About page for his contribution and determination to make WinUtil (and MicroWin) the best software it can be!

* Remove the 'LogoSize' Parameter for About page - Make every sponsor in the sponsors list a link to ChrisTitusTech's Sponsors web link

* Change Theme Option name from 'ConfigTabButtonFontSize' to 'ConfigUpdateButtonFontSize' - Lower its value from 16 to 14

* Change Theme Option name from 'FontSizeHeading' to 'HeadingFontSize' for consistency

* Update 'LinkForegroundColor' for Light Theme to be lighter which'll make link hover color more noticeable

* Update 'Show-CustomDialog' Private Function

- Made a lot of theming/styling choices for Custom Dialogs exposed as parameters.
- Update the documentation for these new parameters in 'Show-CustomDialog' Function.
- Add a Link Hover Effect using 'Add_EVENT' methods (This can be tweaks/tuned-down if needed).
- Made use of 'Title' Parameter for 'Show-CustomDialog' Function inside 'scripts/main.ps1' script, to change Dialog Window Title.
- Now you can change the Logo Size of WinUtil through the 'LogoSize' Theming Option (the option was there, but not used in implementation).

* Preprocessing result

* Fix Settings Popup not closing after losing focus - Add trivial null checks for better debugging of UI code

* Remove unnecessary whitespace indentation in 'main.ps1' script

* Add a new 'Invoke-WPFPopup' Function to Better Handle Showing/Hiding/Toggling of Popups

* Improve 'Invoke-WPFPopup' by @MyDrift-user

Thanks for the improvements :)

---------

Co-authored-by: MyDrift <personal@mdiana.ch>
Co-authored-by: Chris Titus <contact@christitus.com>
2024-12-05 21:22:33 -06:00
Ed Blankenship
e2ce998426
Adding .NET 9.0 runtime to applications config (#3041) 2024-12-05 21:19:49 -06:00
Chris Titus
cf7f161a06
Fix language and Logic to Updates (#3087) 2024-12-05 21:18:46 -06:00
Chris Titus
d6c1fbe4a2
Change install to winget, nuget, msstore (#3088) 2024-12-05 21:18:28 -06:00
MyDrift
0779dd9096
[CI/CD] Update Issue Commands (#3052)
* update issue commands workflow

- remove existing workflow
- copy linutil's workflow into winutil
- add @CodingWonders as allowed user

* remove op from rights

- op could spam and create a ton of new labels, or spam workflow to close, reopen and so one
2024-12-01 14:30:10 -06:00
MyDrift
d48f212be4
[Issue Template] Add Validation (#3067)
* issue template update

- add  issue validation inspired by https://github.com/ChrisTitusTech/linutil/pull/459
- standardize capitalisation of characters in titles
- update feature request to use headers instead of bold text for titles

* use "I checked" for Issue validation
2024-12-01 14:29:04 -06:00
MyDrift
9c52f01204
remove redundant & outdated info in workflow (#3076)
- stale + closing message contains outdated time
- remove mention of how long it has been to simplify it.
2024-12-01 14:28:37 -06:00
43 changed files with 883 additions and 1805 deletions

View File

@ -9,12 +9,11 @@ assignees: ''
## Describe the bug
<!-- A clear and concise description of what the bug is. -->
## To Reproduce
Steps to reproduce the behavior:
## Steps to reproduce
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
4. See the error.
## Expected behavior
<!-- A clear and concise description of what you expected to happen. -->
@ -24,3 +23,8 @@ Steps to reproduce the behavior:
## Additional context
<!-- Add any other context about the problem here. -->
## Issue validation
- [ ] I checked for duplicate issues.
- [ ] I checked for already existing discussions.
- [ ] I checked for an already existing pull request addressing the issue.

View File

@ -4,17 +4,21 @@ about: Suggest an idea for this project
title: ''
labels: 'enhancement'
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
## Is your feature request related to a problem? Please describe
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
**Describe the solution you'd like**
## Describe the solution you'd like
<!-- A clear and concise description of what you want to happen. -->
**Describe alternatives you've considered**
## Describe alternatives you've considered
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
**Additional context**
## Additional context
<!-- Add any other context or screenshots about the feature request here. -->
## Issue validation
- [ ] I checked for duplicate issues.
- [ ] I checked for already existing discussions.
- [ ] I checked for an already existing pull request addressing the issue.

View File

@ -28,8 +28,8 @@ jobs:
days-before-pr-stale: -1
days-before-pr-close: -1
# Sends a message for both the Stale and Close events of an issue.
stale-issue-message: "This issue was marked as stale because it has been inactive for 7 days"
close-issue-message: "This issue was closed because it has been inactive for 7 days since it was marked as stale"
stale-issue-message: "This issue was marked as stale due to inactivity."
close-issue-message: "This issue was closed after remaining stale without updates."
# Increase this value if the project receives a lot of
# PRs (yes.. apparently they're processed no matter what) & Issues.
# Default value for it (according to the docs) is 30

View File

@ -1,11 +1,11 @@
name: Close issue on /close
name: Issue slash commands
on:
issue_comment:
types: [created, edited]
jobs:
closeIssueOnClose:
issueCommands:
# Skip this job if the comment was created/edited on a PR
if: ${{ !github.event.issue.pull_request }}
runs-on: ubuntu-latest
@ -17,6 +17,30 @@ jobs:
steps:
- run: echo "command=false" >> $GITHUB_ENV
- name: Check for /label command
id: check_label_command
run: |
if [[ "${{ contains(github.event.comment.body, '/label') }}" == "true" ]]; then
echo "command=true" >> $GITHUB_ENV
LABEL_NAME=$(echo "${{ github.event.comment.body }}" | awk -F"/label" '/\/label/ { match($2, /'\''([^'\'']*)'\''/, arr); if (arr[1] != "") print arr[1] }')
echo "label_command=true" >> $GITHUB_ENV
echo "label_name=${LABEL_NAME}" >> $GITHUB_ENV
else
echo "label_command=false" >> $GITHUB_ENV
fi
- name: Check for /unlabel command
id: check_unlabel_command
run: |
if [[ "${{ contains(github.event.comment.body, '/unlabel') }}" == "true" ]]; then
echo "command=true" >> $GITHUB_ENV
UNLABEL_NAME=$(echo "${{ github.event.comment.body }}" | awk -F"/unlabel" '/\/unlabel/ { match($2, /'\''([^'\'']*)'\''/, arr); if (arr[1] != "") print arr[1] }')
echo "unlabel_command=true" >> $GITHUB_ENV
echo "unlabel_name=${UNLABEL_NAME}" >> $GITHUB_ENV
else
echo "unlabel_command=false" >> $GITHUB_ENV
fi
- name: Check for /close command
id: check_close_command
run: |
@ -43,15 +67,15 @@ jobs:
id: check_user
if: env.command == 'true'
run: |
ALLOWED_USERS=("ChrisTitusTech" "og-mrk" "Marterich" "MyDrift-user" "Real-MullaC")
ALLOWED_USERS=("ChrisTitusTech" "og-mrk" "Marterich" "MyDrift-user" "Real-MullaC" "CodingWonders")
if [[ " ${ALLOWED_USERS[@]} " =~ " ${{ github.event.comment.user.login }} " ]]; then
echo "user=true" >> $GITHUB_ENV
else
echo "user=false" >> $GITHUB_ENV
exit 0
fi
- name: Close issue if conditions are met
if: env.close_command == 'true' && env.user == 'true'
- name: Close issue
if: env.close_command == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
@ -63,11 +87,29 @@ jobs:
gh issue close $ISSUE_NUMBER --repo ${{ github.repository }}
fi
- name: Reopen issue if conditions are met
if: env.reopen_command == 'true' && env.user == 'true'
- name: Reopen issue
if: env.reopen_command == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
echo Reopening the issue...
gh issue reopen $ISSUE_NUMBER --repo ${{ github.repository }}
- name: Label issue
if: env.label_command == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
echo Labeling the issue...
gh issue edit $ISSUE_NUMBER --repo ${{ github.repository }} --add-label "${{ env.label_name }}"
- name: Remove labels
if: env.unlabel_command == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
echo Unlabeling the issue...
gh issue edit $ISSUE_NUMBER --repo ${{ github.repository }} --remove-label "${{ env.unlabel_name }}"

View File

@ -52,7 +52,7 @@ If you have Issues, refer to [Known Issues](https://christitustech.github.io/win
These are the sponsors that help keep this project alive with monthly contributions.
<!-- sponsors --><a href="https://github.com/TriHydera"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;39857764?u&#x3D;5dbda638f45530582eee1703b4473f2a5e229e28&amp;v&#x3D;4" width="60px" alt="TriHydera" /></a><a href="https://github.com/jozozovko"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;3272468?u&#x3D;4391ed4655e4fd8b56e23b4169e44e2ac9b6cd97&amp;v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/DelDongo"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;127976398?v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/markamos"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;9561861?u&#x3D;3cca179dcff0413538591e57a3abea116d65ce56&amp;v&#x3D;4" width="60px" alt="Mark Amos" /></a><a href="https://github.com/dwelfusius"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;54533224?u&#x3D;a49ea000a8f52adb31382ea69a1a7501b27fefdd&amp;v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/mews-se"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;58894405?v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/jdiegmueller"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;18660571?u&#x3D;601d0a23040a271c86b5d40339f899a6dbf27086&amp;v&#x3D;4" width="60px" alt="Jason A. Diegmueller" /></a><a href="https://github.com/AlanTristar"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;105566568?v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/zepled112"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;65176625?v&#x3D;4" width="60px" alt="wyatt" /></a><a href="https://github.com/altugtekiner"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;105917451?u&#x3D;ee73ff639c7bd9feb4708ab4ba7b14eff80196f7&amp;v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/robertsandrock"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;12015331?v&#x3D;4" width="60px" alt="RMS" /></a><a href="https://github.com/mmomega"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;71956566?v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/KenichiQaz"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;31177857?u&#x3D;efdbae734a4c60a7bb95df4659d0535e60a6fd57&amp;v&#x3D;4" width="60px" alt="Stefan" /></a><a href="https://github.com/paulsheets"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;45240946?u&#x3D;d4db66f8e8d7a2606fe7a5521daf48ca9f097105&amp;v&#x3D;4" width="60px" alt="Paul" /></a><a href="https://github.com/djones369"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;4107092?v&#x3D;4" width="60px" alt="Dave Jones" /></a><a href="https://github.com/anthonymendez"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;19240897?u&#x3D;f82b4be098cac65c8421421b70ebd2d1da85c67e&amp;v&#x3D;4" width="60px" alt="Anthony Mendez" /></a><a href="https://github.com/claudemods"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;73653396?u&#x3D;d64c656fb8db24ef56bb000197532df9b618d06c&amp;v&#x3D;4" width="60px" alt="Claudemods" /></a><a href="https://github.com/FatBastard0"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;173957728?v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/Ascent7910"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;118260621?v&#x3D;4" width="60px" alt="Max" /></a><a href="https://github.com/DursleyGuy"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;140165544?v&#x3D;4" width="60px" alt="DursleyGuy" /></a><a href="https://github.com/YamiSandman616"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;183505690?u&#x3D;c3bd20157058b6215e28f7568d4f8c4fbbe92838&amp;v&#x3D;4" width="60px" alt="Sandman616" /></a><a href="https://github.com/realmuddy"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;30978236?v&#x3D;4" width="60px" alt="Phillip Waters" /></a><a href="https://github.com/Tariq-Al-Zahrani"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;187593049?v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/quaszi"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;51266738?u&#x3D;2e3185214607e51239c5969c866ddd5eb1bdee48&amp;v&#x3D;4" width="60px" alt="" /></a><!-- sponsors -->
<!-- sponsors --><a href="https://github.com/TriHydera"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;39857764?u&#x3D;5dbda638f45530582eee1703b4473f2a5e229e28&amp;v&#x3D;4" width="60px" alt="TriHydera" /></a><a href="https://github.com/jozozovko"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;3272468?u&#x3D;4391ed4655e4fd8b56e23b4169e44e2ac9b6cd97&amp;v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/DelDongo"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;127976398?v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/markamos"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;9561861?u&#x3D;3cca179dcff0413538591e57a3abea116d65ce56&amp;v&#x3D;4" width="60px" alt="Mark Amos" /></a><a href="https://github.com/dwelfusius"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;54533224?u&#x3D;a49ea000a8f52adb31382ea69a1a7501b27fefdd&amp;v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/mews-se"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;58894405?v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/jdiegmueller"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;18660571?u&#x3D;601d0a23040a271c86b5d40339f899a6dbf27086&amp;v&#x3D;4" width="60px" alt="Jason A. Diegmueller" /></a><a href="https://github.com/AlanTristar"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;105566568?v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/zepled112"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;65176625?v&#x3D;4" width="60px" alt="wyatt" /></a><a href="https://github.com/altugtekiner"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;105917451?u&#x3D;ee73ff639c7bd9feb4708ab4ba7b14eff80196f7&amp;v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/robertsandrock"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;12015331?v&#x3D;4" width="60px" alt="RMS" /></a><a href="https://github.com/mmomega"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;71956566?v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/KenichiQaz"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;31177857?u&#x3D;efdbae734a4c60a7bb95df4659d0535e60a6fd57&amp;v&#x3D;4" width="60px" alt="Stefan" /></a><a href="https://github.com/paulsheets"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;45240946?u&#x3D;d4db66f8e8d7a2606fe7a5521daf48ca9f097105&amp;v&#x3D;4" width="60px" alt="Paul" /></a><a href="https://github.com/djones369"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;4107092?v&#x3D;4" width="60px" alt="Dave Jones" /></a><a href="https://github.com/anthonymendez"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;19240897?u&#x3D;f82b4be098cac65c8421421b70ebd2d1da85c67e&amp;v&#x3D;4" width="60px" alt="Anthony Mendez" /></a><a href="https://github.com/claudemods"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;73653396?u&#x3D;d64c656fb8db24ef56bb000197532df9b618d06c&amp;v&#x3D;4" width="60px" alt="Claudemods" /></a><a href="https://github.com/FatBastard0"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;173957728?v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/Ascent7910"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;118260621?v&#x3D;4" width="60px" alt="Max" /></a><a href="https://github.com/DursleyGuy"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;140165544?v&#x3D;4" width="60px" alt="DursleyGuy" /></a><a href="https://github.com/YamiSandman616"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;183505690?u&#x3D;c3bd20157058b6215e28f7568d4f8c4fbbe92838&amp;v&#x3D;4" width="60px" alt="Sandman616" /></a><a href="https://github.com/realmuddy"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;30978236?v&#x3D;4" width="60px" alt="Phillip Waters" /></a><a href="https://github.com/quaszi"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;51266738?u&#x3D;2e3185214607e51239c5969c866ddd5eb1bdee48&amp;v&#x3D;4" width="60px" alt="" /></a><a href="https://github.com/Psyhackological"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;47569716?u&#x3D;66dc5e86731eaf8c6bc78a1bff34420ed2e5402b&amp;v&#x3D;4" width="60px" alt="Konrad Konieczny" /></a><!-- sponsors -->
## 🏅 Thanks to all Contributors
Thanks a lot for spending your time helping Winutil grow. Thanks a lot! Keep rocking 🍻.

28
Test-WingetInstall.ps1 Normal file
View File

@ -0,0 +1,28 @@
# Import the function (adjust the path according to your setup)
. "./functions/private/Get-WinUtilWingetLatest.ps1"
# Set up Information stream to be visible
$InformationPreference = "Continue"
Write-Host "Starting Winget installation test..." -ForegroundColor Cyan
try {
# Test the function with verbose output
Write-Host "Attempting to run Get-WinUtilWingetLatest..." -ForegroundColor Cyan
Get-WinUtilWingetLatest -Verbose
# Verify Winget is working
if (Get-Command winget -ErrorAction SilentlyContinue) {
Write-Host "Success! Winget is installed and accessible." -ForegroundColor Green
# Display Winget version
Write-Host "`nWinget version:" -ForegroundColor Cyan
winget --version
} else {
Write-Host "Warning: Winget is installed but not accessible in the current session. You may need to restart your terminal." -ForegroundColor Yellow
}
} catch {
Write-Host "Error occurred during testing: $($_.Exception.Message)" -ForegroundColor Red
Write-Host "Stack Trace:" -ForegroundColor Red
$_.ScriptStackTrace
}

View File

@ -439,6 +439,14 @@
"link": "https://dotnet.microsoft.com/download/dotnet/8.0",
"winget": "Microsoft.DotNet.DesktopRuntime.8"
},
"dotnet9": {
"category": "Microsoft Tools",
"choco": "dotnet-9.0-runtime",
"content": ".NET Desktop Runtime 9",
"description": ".NET Desktop Runtime 9 is a runtime environment required for running applications developed with .NET 9.",
"link": "https://dotnet.microsoft.com/download/dotnet/9.0",
"winget": "Microsoft.DotNet.DesktopRuntime.9"
},
"dmt": {
"winget": "GNE.DualMonitorTools",
"choco": "dual-monitor-tools",

View File

@ -14,7 +14,6 @@
"WPFTweaksDeleteTempFiles",
"WPFTweaksEndTaskOnTaskbar",
"WPFTweaksRestorePoint",
"WPFTweaksIPv46",
"WPFTweaksPowershell7Tele"
],
"Minimal": [

View File

@ -2,12 +2,12 @@
"shared":{
"CustomDialogFontSize": "12",
"CustomDialogFontSizeHeader": "14",
"CustomDialogIconSize": "25",
"CustomDialogLogoSize": "25",
"CustomDialogWidth": "400",
"CustomDialogHeight": "200",
"FontSize": "12",
"FontFamily": "Arial",
"FontSizeHeading": "16",
"HeadingFontSize": "16",
"HeaderFontFamily": "Consolas, Monaco",
"CheckBoxBulletDecoratorSize": "14",
"CheckBoxMargin": "15,0,0,2",
@ -27,7 +27,7 @@
"ButtonFontFamily": "Arial",
"ButtonWidth": "200",
"ButtonHeight": "25",
"ConfigTabButtonFontSize": "16",
"ConfigUpdateButtonFontSize": "14",
"SearchBarWidth": "200",
"SearchBarHeight": "26",
"SearchBarTextBoxFontSize": "12",
@ -44,7 +44,7 @@
"MainForegroundColor": "#232629",
"MainBackgroundColor": "#F7F7F7",
"LabelBackgroundColor": "#F7F7F7",
"LinkForegroundColor": "#232629",
"LinkForegroundColor": "#484848",
"LinkHoverForegroundColor": "#232629",
"ScrollBarBackgroundColor": "#4A4D52",
"ScrollBarHoverColor": "#5A5D62",

View File

@ -2320,17 +2320,10 @@
"microsoft.windowscommunicationsapps",
"Microsoft.WindowsFeedbackHub",
"Microsoft.WindowsMaps",
"Microsoft.YourPhone",
"Microsoft.WindowsSoundRecorder",
"Microsoft.XboxApp",
"Microsoft.ConnectivityStore",
"Microsoft.ScreenSketch",
"Microsoft.Xbox.TCUI",
"Microsoft.XboxGameOverlay",
"Microsoft.XboxGameCallableUI",
"Microsoft.XboxSpeechToTextOverlay",
"Microsoft.MixedReality.Portal",
"Microsoft.XboxIdentityProvider",
"Microsoft.ZuneMusic",
"Microsoft.ZuneVideo",
"Microsoft.Getstarted",
@ -3201,9 +3194,9 @@
"WPFTweaksIPv46": {
"Content": "Prefer IPv4 over IPv6",
"Description": "To set the IPv4 preference can have latency and security benefits on private networks where IPv6 is not configured.",
"category": "Essential Tweaks",
"category": "z__Advanced Tweaks - CAUTION",
"panel": "1",
"Order": "a005_",
"Order": "a023_",
"registry": [
{
"Path": "HKLM:\\SYSTEM\\CurrentControlSet\\Services\\Tcpip6\\Parameters",
@ -3302,6 +3295,38 @@
"panel": "2",
"Order": "a100_",
"Type": "Toggle",
"registry": [
{
"Path": "HKCU:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
"Name": "AppsUseLightTheme",
"Value": "0",
"OriginalValue": "1",
"Type": "DWord"
},
{
"Path": "HKCU:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
"Name": "SystemUsesLightTheme",
"Value": "0",
"OriginalValue": "1",
"Type": "DWord"
}
],
"InvokeScript": [
"
Invoke-WinUtilExplorerUpdate
if ($sync.ThemeButton.Content -eq [char]0xF08C) {
Invoke-WinutilThemeChange -theme \"Auto\"
}
"
],
"UndoScript": [
"
Invoke-WinUtilExplorerUpdate
if ($sync.ThemeButton.Content -eq [char]0xF08C) {
Invoke-WinutilThemeChange -theme \"Auto\"
}
"
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/DarkMode"
},
"WPFToggleBingSearch": {
@ -3311,6 +3336,15 @@
"panel": "2",
"Order": "a101_",
"Type": "Toggle",
"registry": [
{
"Path": "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Search",
"Name": "BingSearchEnabled",
"Value": "1",
"OriginalValue": "0",
"Type": "DWord"
}
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/BingSearch"
},
"WPFToggleNumLock": {
@ -3320,6 +3354,22 @@
"panel": "2",
"Order": "a102_",
"Type": "Toggle",
"registry": [
{
"Path": "HKU:\\.Default\\Control Panel\\Keyboard",
"Name": "InitialKeyboardIndicators",
"Value": "2",
"OriginalValue": "0",
"Type": "DWord"
},
{
"Path": "HKCU:\\Control Panel\\Keyboard",
"Name": "InitialKeyboardIndicators",
"Value": "2",
"OriginalValue": "0",
"Type": "DWord"
}
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/NumLock"
},
"WPFToggleVerboseLogon": {
@ -3329,6 +3379,15 @@
"panel": "2",
"Order": "a103_",
"Type": "Toggle",
"registry": [
{
"Path": "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
"Name": "VerboseStatus",
"Value": "1",
"OriginalValue": "0",
"Type": "DWord"
}
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/VerboseLogon"
},
"WPFToggleSnapWindow": {
@ -3338,6 +3397,15 @@
"panel": "2",
"Order": "a104_",
"Type": "Toggle",
"registry": [
{
"Path": "HKCU:\\Control Panel\\Desktop",
"Name": "WindowArrangementActive",
"Value": "1",
"OriginalValue": "0",
"Type": "String"
}
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/SnapWindow"
},
"WPFToggleSnapFlyout": {
@ -3347,6 +3415,25 @@
"panel": "2",
"Order": "a105_",
"Type": "Toggle",
"registry": [
{
"Path": "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
"Name": "EnableSnapAssistFlyout",
"Value": "1",
"OriginalValue": "0",
"Type": "DWord"
}
],
"InvokeScript": [
"
Invoke-WinUtilExplorerUpdate -action \"restart\"
"
],
"UndoScript": [
"
Invoke-WinUtilExplorerUpdate -action \"restart\"
"
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/SnapFlyout"
},
"WPFToggleSnapSuggestion": {
@ -3356,6 +3443,25 @@
"panel": "2",
"Order": "a106_",
"Type": "Toggle",
"registry": [
{
"Path": "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
"Name": "SnapAssist",
"Value": "1",
"OriginalValue": "0",
"Type": "DWord"
}
],
"InvokeScript": [
"
Invoke-WinUtilExplorerUpdate -action \"restart\"
"
],
"UndoScript": [
"
Invoke-WinUtilExplorerUpdate -action \"restart\"
"
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/SnapSuggestion"
},
"WPFToggleMouseAcceleration": {
@ -3365,6 +3471,29 @@
"panel": "2",
"Order": "a107_",
"Type": "Toggle",
"registry": [
{
"Path": "HKCU:\\Control Panel\\Mouse",
"Name": "MouseSpeed",
"Value": "1",
"OriginalValue": "0",
"Type": "DWord"
},
{
"Path": "HKCU:\\Control Panel\\Mouse",
"Name": "MouseThreshold1",
"Value": "6",
"OriginalValue": "0",
"Type": "DWord"
},
{
"Path": "HKCU:\\Control Panel\\Mouse",
"Name": "MouseThreshold2",
"Value": "10",
"OriginalValue": "0",
"Type": "DWord"
}
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/MouseAcceleration"
},
"WPFToggleStickyKeys": {
@ -3374,6 +3503,15 @@
"panel": "2",
"Order": "a108_",
"Type": "Toggle",
"registry": [
{
"Path": "HKCU:\\Control Panel\\Accessibility\\StickyKeys",
"Name": "Flags",
"Value": "510",
"OriginalValue": "58",
"Type": "DWord"
}
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/StickyKeys"
},
"WPFToggleHiddenFiles": {
@ -3383,6 +3521,25 @@
"panel": "2",
"Order": "a200_",
"Type": "Toggle",
"registry": [
{
"Path": "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
"Name": "Hidden",
"Value": "1",
"OriginalValue": "0",
"Type": "DWord"
}
],
"InvokeScript": [
"
Invoke-WinUtilExplorerUpdate -action \"restart\"
"
],
"UndoScript": [
"
Invoke-WinUtilExplorerUpdate -action \"restart\"
"
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/HiddenFiles"
},
"WPFToggleShowExt": {
@ -3392,6 +3549,25 @@
"panel": "2",
"Order": "a201_",
"Type": "Toggle",
"registry": [
{
"Path": "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
"Name": "HideFileExt",
"Value": "0",
"OriginalValue": "1",
"Type": "DWord"
}
],
"InvokeScript": [
"
Invoke-WinUtilExplorerUpdate -action \"restart\"
"
],
"UndoScript": [
"
Invoke-WinUtilExplorerUpdate -action \"restart\"
"
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/ShowExt"
},
"WPFToggleTaskbarSearch": {
@ -3401,6 +3577,15 @@
"panel": "2",
"Order": "a202_",
"Type": "Toggle",
"registry": [
{
"Path": "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Search",
"Name": "SearchboxTaskbarMode",
"Value": "1",
"OriginalValue": "0",
"Type": "DWord"
}
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/TaskbarSearch"
},
"WPFToggleTaskView": {
@ -3410,6 +3595,15 @@
"panel": "2",
"Order": "a203_",
"Type": "Toggle",
"registry": [
{
"Path": "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
"Name": "ShowTaskViewButton",
"Value": "1",
"OriginalValue": "0",
"Type": "DWord"
}
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/TaskView"
},
"WPFToggleTaskbarWidgets": {
@ -3419,6 +3613,15 @@
"panel": "2",
"Order": "a204_",
"Type": "Toggle",
"registry": [
{
"Path": "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
"Name": "TaskbarDa",
"Value": "1",
"OriginalValue": "0",
"Type": "DWord"
}
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/TaskbarWidgets"
},
"WPFToggleTaskbarAlignment": {
@ -3428,6 +3631,15 @@
"panel": "2",
"Order": "a204_",
"Type": "Toggle",
"registry": [
{
"Path": "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
"Name": "TaskbarAl",
"Value": "1",
"OriginalValue": "0",
"Type": "DWord"
}
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/TaskbarAlignment"
},
"WPFToggleDetailedBSoD": {
@ -3437,6 +3649,22 @@
"panel": "2",
"Order": "a205_",
"Type": "Toggle",
"registry": [
{
"Path": "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\CrashControl",
"Name": "DisplayParameters",
"Value": "1",
"OriginalValue": "0",
"Type": "DWord"
},
{
"Path": "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\CrashControl",
"Name": "DisableEmoticon",
"Value": "1",
"OriginalValue": "0",
"Type": "DWord"
}
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/DetailedBSoD"
},
"WPFOOSUbutton": {

View File

@ -13,75 +13,48 @@ Function Get-WinUtilToggleStatus {
#>
Param($ToggleSwitch)
if($ToggleSwitch -eq "WPFToggleDarkMode") {
$app = (Get-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize').AppsUseLightTheme
$system = (Get-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize').SystemUsesLightTheme
return $app -eq 0 -and $system -eq 0
}
if($ToggleSwitch -eq "WPFToggleBingSearch") {
$bingsearch = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Search').BingSearchEnabled
return $bingsearch -ne 0
}
if($ToggleSwitch -eq "WPFToggleNumLock") {
$numlockvalue = (Get-ItemProperty -path 'HKCU:\Control Panel\Keyboard').InitialKeyboardIndicators
return $numlockvalue -eq 2
}
if($ToggleSwitch -eq "WPFToggleVerboseLogon") {
$VerboseStatusvalue = (Get-ItemProperty -path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System').VerboseStatus
return $VerboseStatusvalue -eq 1
}
if($ToggleSwitch -eq "WPFToggleShowExt") {
$hideextvalue = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').HideFileExt
return $hideextvalue -eq 0
}
if($ToggleSwitch -eq "WPFToggleSnapWindow") {
$hidesnap = (Get-ItemProperty -path 'HKCU:\Control Panel\Desktop').WindowArrangementActive
return $hidesnap -ne 0
}
if($ToggleSwitch -eq "WPFToggleSnapFlyout") {
$hidesnap = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').EnableSnapAssistFlyout
return $hidesnap -ne 0
}
if($ToggleSwitch -eq "WPFToggleSnapSuggestion") {
$hidesnap = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').SnapAssist
return $hidesnap -ne 0
}
if($ToggleSwitch -eq "WPFToggleMouseAcceleration") {
$MouseSpeed = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseSpeed
$MouseThreshold1 = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseThreshold1
$MouseThreshold2 = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseThreshold2
return $MouseSpeed -eq 1 -and $MouseThreshold1 -eq 6 -and $MouseThreshold2 -eq 10
}
if($ToggleSwitch -eq "WPFToggleTaskbarSearch") {
$SearchButton = (Get-ItemProperty -path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search").SearchboxTaskbarMode
return $SearchButton -ne 0
}
if ($ToggleSwitch -eq "WPFToggleStickyKeys") {
$StickyKeys = (Get-ItemProperty -path 'HKCU:\Control Panel\Accessibility\StickyKeys').Flags
return $StickyKeys -ne 58
}
if ($ToggleSwitch -eq "WPFToggleTaskView") {
$TaskView = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').ShowTaskViewButton
return $TaskView -ne 0
$ToggleSwitchReg = $sync.configs.tweaks.$ToggleSwitch.registry
try {
if (($ToggleSwitchReg.path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {
$null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS)
if (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue) {
Write-Debug "HKU drive created successfully"
} else {
Write-Debug "Failed to create HKU drive"
}
}
} catch {
Write-Error "An error occurred regarding the HKU Drive: $_"
return $false
}
if ($ToggleSwitch -eq "WPFToggleHiddenFiles") {
$HiddenFiles = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').Hidden
return $HiddenFiles -ne 0
}
if ($ToggleSwitchReg) {
$count = 0
if ($ToggleSwitch -eq "WPFToggleTaskbarWidgets") {
$TaskbarWidgets = (Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced").TaskBarDa
return $TaskbarWidgets -ne 0
}
if ($ToggleSwitch -eq "WPFToggleTaskbarAlignment") {
$TaskbarAlignment = (Get-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced").TaskbarAl
return $TaskbarAlignment -ne 0
}
if ($ToggleSwitch -eq "WPFToggleDetailedBSoD") {
$DetailedBSoD1 = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl').DisplayParameters
$DetailedBSoD2 = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl').DisableEmoticon
return !(($DetailedBSoD1 -eq 0) -or ($DetailedBSoD2 -eq 0) -or !$DetailedBSoD1 -or !$DetailedBSoD2)
foreach ($regentry in $ToggleSwitchReg) {
try {
$regstate = (Get-ItemProperty -path $regentry.Path).$($regentry.Name)
if ($regstate -eq $regentry.Value) {
$count += 1
Write-Debug "$($regentry.Name) is true (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))"
} else {
Write-Debug "$($regentry.Name) is false (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))"
}
} catch {
Write-Error "An error occurred while accessing registry entry $($regentry.Path): $_"
}
}
if ($count -eq $ToggleSwitchReg.Count) {
Write-Debug "$($ToggleSwitchReg.Name) is true (count: $count)"
return $true
} else {
Write-Debug "$($ToggleSwitchReg.Name) is false (count: $count)"
return $false
}
} else {
return $false
}
}

View File

@ -1,26 +1,104 @@
function Get-WinUtilWingetLatest {
[CmdletBinding()]
param()
<#
.SYNOPSIS
Uses GitHub API to check for the latest release of Winget.
.DESCRIPTION
This function grabs the latest version of Winget and returns the download path to Install-WinUtilWinget for installation.
This function first attempts to update WinGet using winget itself, then falls back to manual installation if needed.
#>
# Invoke-WebRequest is notoriously slow when the byte progress is displayed. The following lines disable the progress bar and reset them at the end of the function
$PreviousProgressPreference = $ProgressPreference
$ProgressPreference = "silentlyContinue"
$ProgressPreference = "SilentlyContinue"
$InformationPreference = 'Continue'
try {
# Grabs the latest release of Winget from the Github API for the install process.
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/microsoft/Winget-cli/releases/latest" -Method Get -ErrorAction Stop
$latestVersion = $response.tag_name #Stores version number of latest release.
$licenseWingetUrl = $response.assets.browser_download_url | Where-Object {$_ -like "*License1.xml"} #Index value for License file.
Write-Host "Latest Version:`t$($latestVersion)`n"
Write-Host "Downloading..."
$assetUrl = $response.assets.browser_download_url | Where-Object {$_ -like "*Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"}
Invoke-WebRequest -Uri $licenseWingetUrl -OutFile $ENV:TEMP\License1.xml
# The only pain is that the msixbundle for winget-cli is 246MB. In some situations this can take a bit, with slower connections.
Invoke-WebRequest -Uri $assetUrl -OutFile $ENV:TEMP\Microsoft.DesktopAppInstaller.msixbundle
} catch {
throw [WingetFailedInstall]::new('Failed to get latest Winget release and license')
$wingetCmd = Get-Command winget -ErrorAction Stop
Write-Information "Attempting to update WinGet using WinGet..."
$result = Start-Process -FilePath "`"$($wingetCmd.Source)`"" -ArgumentList "install -e --accept-source-agreements --accept-package-agreements Microsoft.AppInstaller" -Wait -NoNewWindow -PassThru
if ($result.ExitCode -ne 0) {
throw "WinGet update failed with exit code: $($result.ExitCode)"
}
return $true
}
catch {
Write-Information "WinGet not found or update failed. Attempting to install from Microsoft Store..."
try {
# Try to close any running WinGet processes
Get-Process -Name "DesktopAppInstaller", "winget" -ErrorAction SilentlyContinue | ForEach-Object {
Write-Information "Stopping running WinGet process..."
$_.Kill()
Start-Sleep -Seconds 2
}
# Try to load Windows Runtime assemblies more reliably
$null = [System.Runtime.WindowsRuntime.WindowsRuntimeSystemExtensions]
Add-Type -AssemblyName System.Runtime.WindowsRuntime
# Load required assemblies from Windows SDK
$null = @(
[Windows.Management.Deployment.PackageManager, Windows.Management.Deployment, ContentType = WindowsRuntime]
[Windows.Foundation.Uri, Windows.Foundation, ContentType = WindowsRuntime]
[Windows.Management.Deployment.DeploymentOptions, Windows.Management.Deployment, ContentType = WindowsRuntime]
)
# Initialize PackageManager
$packageManager = New-Object Windows.Management.Deployment.PackageManager
# Rest of the Microsoft Store installation logic
$appxPackage = "https://aka.ms/getwinget"
$uri = New-Object Windows.Foundation.Uri($appxPackage)
$deploymentOperation = $packageManager.AddPackageAsync($uri, $null, "Add")
# Add timeout check for deployment operation
$timeout = 300
$timer = [System.Diagnostics.Stopwatch]::StartNew()
while ($deploymentOperation.Status -eq 0) {
if ($timer.Elapsed.TotalSeconds -gt $timeout) {
throw "Installation timed out after $timeout seconds"
}
Start-Sleep -Milliseconds 100
}
if ($deploymentOperation.Status -eq 1) {
Write-Information "Successfully installed WinGet from Microsoft Store"
return $true
} else {
throw "Installation failed with status: $($deploymentOperation.Status)"
}
}
catch [System.Management.Automation.RuntimeException] {
Write-Information "Windows Runtime components not available. Attempting manual download..."
try {
# Try to close any running WinGet processes
Get-Process -Name "DesktopAppInstaller", "winget" -ErrorAction SilentlyContinue | ForEach-Object {
Write-Information "Stopping running WinGet process..."
$_.Kill()
Start-Sleep -Seconds 2
}
# Fallback to direct download from GitHub
$apiUrl = "https://api.github.com/repos/microsoft/winget-cli/releases/latest"
$release = Invoke-RestMethod -Uri $apiUrl
$msixBundleUrl = ($release.assets | Where-Object { $_.name -like "*.msixbundle" }).browser_download_url
$tempFile = Join-Path $env:TEMP "Microsoft.DesktopAppInstaller.msixbundle"
Invoke-WebRequest -Uri $msixBundleUrl -OutFile $tempFile
Add-AppxPackage -Path $tempFile -ErrorAction Stop
Remove-Item $tempFile -Force
Write-Information "Successfully installed WinGet from GitHub release"
return $true
}
catch {
Write-Error "Failed to install WinGet: $_"
return $false
}
}
catch {
Write-Error "Failed to install WinGet: $_"
return $false
}
}
$ProgressPreference = $PreviousProgressPreference
}

View File

@ -1,28 +0,0 @@
function Get-WinUtilWingetPrerequisites {
<#
.SYNOPSIS
Downloads the Winget Prereqs.
.DESCRIPTION
Downloads Prereqs for Winget. Version numbers are coded as variables and can be updated as uncommonly as Microsoft updates the prereqs.
#>
# I don't know of a way to detect the prereqs automatically, so if someone has a better way of defining these, that would be great.
# Microsoft.VCLibs version rarely changes, but for future compatibility I made it a variable.
$versionVCLibs = "14.00"
$fileVCLibs = "https://aka.ms/Microsoft.VCLibs.x64.${versionVCLibs}.Desktop.appx"
# Write-Host "$fileVCLibs"
# Microsoft.UI.Xaml version changed recently, so I made the version numbers variables.
$versionUIXamlMinor = "2.8"
$versionUIXamlPatch = "2.8.6"
$fileUIXaml = "https://github.com/microsoft/microsoft-ui-xaml/releases/download/v${versionUIXamlPatch}/Microsoft.UI.Xaml.${versionUIXamlMinor}.x64.appx"
# Write-Host "$fileUIXaml"
try {
Write-Host "Downloading Microsoft.VCLibs Dependency..."
Invoke-WebRequest -Uri $fileVCLibs -OutFile $ENV:TEMP\Microsoft.VCLibs.x64.Desktop.appx
Write-Host "Downloading Microsoft.UI.Xaml Dependency...`n"
Invoke-WebRequest -Uri $fileUIXaml -OutFile $ENV:TEMP\Microsoft.UI.Xaml.x64.appx
} catch {
throw [WingetFailedInstall]::new('Failed to install prerequsites')
}
}

View File

@ -35,15 +35,8 @@ function Install-WinUtilWinget {
# Install Winget via GitHub method.
# Used part of my own script with some modification: ruxunderscore/windows-initialization
Write-Host "Downloading Winget Prerequsites`n"
Get-WinUtilWingetPrerequisites
Write-Host "Downloading Winget and License File`r"
Get-WinUtilWingetLatest
Write-Host "Installing Winget w/ Prerequsites`r"
Add-AppxProvisionedPackage -Online -PackagePath $ENV:TEMP\Microsoft.DesktopAppInstaller.msixbundle -DependencyPackagePath $ENV:TEMP\Microsoft.VCLibs.x64.Desktop.appx, $ENV:TEMP\Microsoft.UI.Xaml.x64.appx -LicensePath $ENV:TEMP\License1.xml
Write-Host "Manually adding Winget Sources, from Winget CDN."
Add-AppxPackage -Path https://cdn.winget.microsoft.com/cache/source.msix #Seems some installs of Winget don't add the repo source, this should makes sure that it's installed every time.
Write-Host "Winget Installed" -ForegroundColor Green
Write-Host "Enabling NuGet and Module..."
Install-PackageProvider -Name NuGet -Force
Install-Module -Name Microsoft.WinGet.Client -Force
@ -51,18 +44,7 @@ function Install-WinUtilWinget {
Write-Output "Refreshing Environment Variables...`n"
$ENV:PATH = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
} catch {
Write-Host "Failure detected while installing via GitHub method. Continuing with Chocolatey method as fallback." -ForegroundColor Red
# In case install fails via GitHub method.
try {
# Install Choco if not already present
Install-WinUtilChoco
Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "choco install winget-cli"
Write-Host "Winget Installed" -ForegroundColor Green
Write-Output "Refreshing Environment Variables...`n"
$ENV:PATH = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
} catch {
throw [WingetFailedInstall]::new('Failed to install!')
}
Write-Error "Failed to install Winget: $($_.Exception.Message)"
}
}

View File

@ -1,30 +0,0 @@
function Invoke-WinUtilBingSearch {
<#
.SYNOPSIS
Disables/Enables Bing Search
.PARAMETER Enabled
Indicates whether to enable or disable Bing Search
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Enabling Bing Search"
$value = 1
} else {
Write-Host "Disabling Bing Search"
$value = 0
}
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search"
Set-ItemProperty -Path $Path -Name BingSearchEnabled -Value $value
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -43,7 +43,7 @@ Function Invoke-WinUtilCurrentSystem {
if($CheckBox -eq "tweaks") {
if(!(Test-Path 'HKU:\')) {New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS}
if(!(Test-Path 'HKU:\')) {$null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS)}
$ScheduledTasks = Get-ScheduledTask
$sync.configs.tweaks | Get-Member -MemberType NoteProperty | ForEach-Object {

View File

@ -1,37 +0,0 @@
Function Invoke-WinUtilDarkMode {
<#
.SYNOPSIS
Enables/Disables Dark Mode
.PARAMETER DarkMoveEnabled
Indicates the current dark mode state
#>
Param($DarkMoveEnabled)
try {
if ($DarkMoveEnabled -eq $false) {
Write-Host "Enabling Dark Mode"
$DarkMoveValue = 0
} else {
Write-Host "Disabling Dark Mode"
$DarkMoveValue = 1
}
$Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
Set-ItemProperty -Path $Path -Name AppsUseLightTheme -Value $DarkMoveValue
Set-ItemProperty -Path $Path -Name SystemUsesLightTheme -Value $DarkMoveValue
Invoke-WinUtilExplorerRefresh
# Update Winutil Theme if the Theme Button shows the Icon for Auto
if ($sync.ThemeButton.Content -eq [char]0xF08C) {
Invoke-WinutilThemeChange -theme "Auto"
}
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -1,34 +0,0 @@
Function Invoke-WinUtilDetailedBSoD {
<#
.SYNOPSIS
Enables/Disables Detailed BSoD
(Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl' -Name 'DisplayParameters').DisplayParameters
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Enabling Detailed BSoD"
$value = 1
} else {
Write-Host "Disabling Detailed BSoD"
$value =0
}
$Path = "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl"
$dwords = ("DisplayParameters", "DisableEmoticon")
foreach ($name in $dwords) {
Set-ItemProperty -Path $Path -Name $name -Value $value
}
Set-ItemProperty -Path $Path -Name DisplayParameters -Value $value
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -1,33 +0,0 @@
function Invoke-WinUtilExplorerRefresh {
<#
.SYNOPSIS
Refreshes the Windows Explorer
#>
Invoke-WPFRunspace -DebugPreference $DebugPreference -ScriptBlock {
# Send the WM_SETTINGCHANGE message to all windows
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class Win32 {
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern IntPtr SendMessageTimeout(
IntPtr hWnd,
uint Msg,
IntPtr wParam,
string lParam,
uint fuFlags,
uint uTimeout,
out IntPtr lpdwResult);
}
"@
$HWND_BROADCAST = [IntPtr]0xffff
$WM_SETTINGCHANGE = 0x1A
$SMTO_ABORTIFHUNG = 0x2
$timeout = 100
# Send the broadcast message to all windows
[Win32]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, [IntPtr]::Zero, "ImmersiveColorSet", $SMTO_ABORTIFHUNG, $timeout, [ref]([IntPtr]::Zero))
}
}

View File

@ -0,0 +1,43 @@
function Invoke-WinUtilExplorerUpdate {
<#
.SYNOPSIS
Refreshes the Windows Explorer
#>
param (
[string]$action = "refresh"
)
if ($action -eq "refresh") {
Invoke-WPFRunspace -DebugPreference $DebugPreference -ScriptBlock {
# Send the WM_SETTINGCHANGE message to all windows
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class Win32 {
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern IntPtr SendMessageTimeout(
IntPtr hWnd,
uint Msg,
IntPtr wParam,
string lParam,
uint fuFlags,
uint uTimeout,
out IntPtr lpdwResult);
}
"@
$HWND_BROADCAST = [IntPtr]0xffff
$WM_SETTINGCHANGE = 0x1A
$SMTO_ABORTIFHUNG = 0x2
$timeout = 100
# Send the broadcast message to all windows
[Win32]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, [IntPtr]::Zero, "ImmersiveColorSet", $SMTO_ABORTIFHUNG, $timeout, [ref]([IntPtr]::Zero))
}
} elseif ($action -eq "restart") {
# Restart the Windows Explorer
taskkill.exe /F /IM "explorer.exe"
Start-Process "explorer.exe"
}
}

View File

@ -1,30 +0,0 @@
function Invoke-WinUtilHiddenFiles {
<#
.SYNOPSIS
Enable/Disable Hidden Files
.PARAMETER Enabled
Indicates whether to enable or disable Hidden Files
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Enabling Hidden Files"
$value = 1
} else {
Write-Host "Disabling Hidden Files"
$value = 0
}
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
Set-ItemProperty -Path $Path -Name Hidden -Value $value
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -1,38 +0,0 @@
Function Invoke-WinUtilMouseAcceleration {
<#
.SYNOPSIS
Enables/Disables Mouse Acceleration
.PARAMETER DarkMoveEnabled
Indicates the current Mouse Acceleration State
#>
Param($MouseAccelerationEnabled)
try {
if ($MouseAccelerationEnabled -eq $false) {
Write-Host "Enabling Mouse Acceleration"
$MouseSpeed = 1
$MouseThreshold1 = 6
$MouseThreshold2 = 10
} else {
Write-Host "Disabling Mouse Acceleration"
$MouseSpeed = 0
$MouseThreshold1 = 0
$MouseThreshold2 = 0
}
$Path = "HKCU:\Control Panel\Mouse"
Set-ItemProperty -Path $Path -Name MouseSpeed -Value $MouseSpeed
Set-ItemProperty -Path $Path -Name MouseThreshold1 -Value $MouseThreshold1
Set-ItemProperty -Path $Path -Name MouseThreshold2 -Value $MouseThreshold2
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -1,31 +0,0 @@
function Invoke-WinUtilNumLock {
<#
.SYNOPSIS
Disables/Enables NumLock on startup
.PARAMETER Enabled
Indicates whether to enable or disable Numlock on startup
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Enabling Numlock on startup"
$value = 2
} else {
Write-Host "Disabling Numlock on startup"
$value = 0
}
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
$HKUPath = "HKU:\.Default\Control Panel\Keyboard"
$HKCUPath = "HKCU:\Control Panel\Keyboard"
Set-ItemProperty -Path $HKUPath -Name InitialKeyboardIndicators -Value $value
Set-ItemProperty -Path $HKCUPath -Name InitialKeyboardIndicators -Value $value
}
Catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -1,27 +0,0 @@
function Invoke-WinUtilShowExt {
<#
.SYNOPSIS
Disables/Enables Show file Extentions
.PARAMETER Enabled
Indicates whether to enable or disable Show file extentions
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Showing file extentions"
$value = 0
} else {
Write-Host "hiding file extensions"
$value = 1
}
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
Set-ItemProperty -Path $Path -Name HideFileExt -Value $value
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -1,30 +0,0 @@
function Invoke-WinUtilSnapFlyout {
<#
.SYNOPSIS
Disables/Enables Snap Assist Flyout on startup
.PARAMETER Enabled
Indicates whether to enable or disable Snap Assist Flyout on startup
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Enabling Snap Assist Flyout On startup"
$value = 1
} else {
Write-Host "Disabling Snap Assist Flyout On startup"
$value = 0
}
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
taskkill.exe /F /IM "explorer.exe"
Set-ItemProperty -Path $Path -Name EnableSnapAssistFlyout -Value $value
Start-Process "explorer.exe"
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -1,30 +0,0 @@
function Invoke-WinUtilSnapSuggestion {
<#
.SYNOPSIS
Disables/Enables Snap Assist Suggestions on startup
.PARAMETER Enabled
Indicates whether to enable or disable Snap Assist Suggestions on startup
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Enabling Snap Assist Suggestion On startup"
$value = 1
} else {
Write-Host "Disabling Snap Assist Suggestion On startup"
$value = 0
}
# taskkill.exe /F /IM "explorer.exe"
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
taskkill.exe /F /IM "explorer.exe"
Set-ItemProperty -Path $Path -Name SnapAssist -Value $value
Start-Process "explorer.exe"
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -1,27 +0,0 @@
function Invoke-WinUtilSnapWindow {
<#
.SYNOPSIS
Disables/Enables Snapping Windows on startup
.PARAMETER Enabled
Indicates whether to enable or disable Snapping Windows on startup
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Enabling Snap Windows On startup | Relogin Required"
$value = 1
} else {
Write-Host "Disabling Snap Windows On startup | Relogin Required"
$value = 0
}
$Path = "HKCU:\Control Panel\Desktop"
Set-ItemProperty -Path $Path -Name WindowArrangementActive -Value $value
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -1,27 +0,0 @@
Function Invoke-WinUtilStickyKeys {
<#
.SYNOPSIS
Disables/Enables Sticky Keyss on startup
.PARAMETER Enabled
Indicates whether to enable or disable Sticky Keys on startup
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Enabling Sticky Keys On startup"
$value = 510
} else {
Write-Host "Disabling Sticky Keys On startup"
$value = 58
}
$Path = "HKCU:\Control Panel\Accessibility\StickyKeys"
Set-ItemProperty -Path $Path -Name Flags -Value $value
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -1,30 +0,0 @@
function Invoke-WinUtilTaskView {
<#
.SYNOPSIS
Enable/Disable Task View
.PARAMETER Enabled
Indicates whether to enable or disable Task View
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Enabling Task View"
$value = 1
} else {
Write-Host "Disabling Task View"
$value = 0
}
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
Set-ItemProperty -Path $Path -Name ShowTaskViewButton -Value $value
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -1,30 +0,0 @@
function Invoke-WinUtilTaskbarAlignment {
<#
.SYNOPSIS
Switches between Center & Left Taskbar Alignment
.PARAMETER Enabled
Indicates whether to make Taskbar Alignment Center or Left
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Making Taskbar Alignment to the Center"
$value = 1
} else {
Write-Host "Making Taskbar Alignment to the Left"
$value = 0
}
$Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
Set-ItemProperty -Path $Path -Name "TaskbarAl" -Value $value
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -1,30 +0,0 @@
function Invoke-WinUtilTaskbarSearch {
<#
.SYNOPSIS
Enable/Disable Taskbar Search Button.
.PARAMETER Enabled
Indicates whether to enable or disable Taskbar Search Button.
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Enabling Search Button"
$value = 1
} else {
Write-Host "Disabling Search Button"
$value = 0
}
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search\"
Set-ItemProperty -Path $Path -Name SearchboxTaskbarMode -Value $value
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -1,30 +0,0 @@
function Invoke-WinUtilTaskbarWidgets {
<#
.SYNOPSIS
Enable/Disable Taskbar Widgets
.PARAMETER Enabled
Indicates whether to enable or disable Taskbar Widgets
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Enabling Taskbar Widgets"
$value = 1
} else {
Write-Host "Disabling Taskbar Widgets"
$value = 0
}
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
Set-ItemProperty -Path $Path -Name TaskbarDa -Value $value
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -21,6 +21,10 @@ function Invoke-WinUtilTweaks {
$KeepServiceStartup = $true
)
if ($Checkbox -contains "Toggle") {
$CheckBox = $sync.configs.tweaks.$CheckBox
}
Write-Debug "Tweaks: $($CheckBox)"
if($undo) {
$Values = @{
@ -73,6 +77,14 @@ function Invoke-WinUtilTweaks {
if($sync.configs.tweaks.$CheckBox.registry) {
$sync.configs.tweaks.$CheckBox.registry | ForEach-Object {
Write-Debug "$($psitem.Name) and state is $($psitem.$($values.registry))"
if (($psitem.Path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {
$null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS)
if (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue) {
Write-Debug "HKU drive created successfully"
} else {
Write-Debug "Failed to create HKU drive"
}
}
Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry)
}
}

View File

@ -1,27 +0,0 @@
function Invoke-WinUtilVerboseLogon {
<#
.SYNOPSIS
Disables/Enables VerboseLogon Messages
.PARAMETER Enabled
Indicates whether to enable or disable VerboseLogon messages
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Enabling Verbose Logon Messages"
$value = 1
} else {
Write-Host "Disabling Verbose Logon Messages"
$value = 0
}
$Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
Set-ItemProperty -Path $Path -Name VerboseStatus -Value $value
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -6,6 +6,9 @@ function Show-CustomDialog {
.DESCRIPTION
This function creates a custom dialog box with the specified message and additional elements such as an image, heading, and an OK button. The dialog box is designed with a green border, rounded corners, and a black background.
.PARAMETER Title
The Title to use for the dialog window's Title Bar, this will not be visible by the user, as window styling is set to None.
.PARAMETER Message
The message to be displayed in the dialog box.
@ -16,60 +19,102 @@ function Show-CustomDialog {
The height of the custom dialog window.
.PARAMETER FontSize
The Font Size for text shown inside the custom dialog window.
The Font Size of message shown inside custom dialog window.
.PARAMETER HeaderFontSize
The Font Size for the Header of the custom dialog window.
The Font Size for the Header of custom dialog window.
.PARAMETER IconSize
The Size to use for Icon inside the custom dialog window.
.PARAMETER LogoSize
The Size of the Logo used inside the custom dialog window.
.PARAMETER ForegroundColor
The Foreground Color of dialog window title & message.
.PARAMETER BackgroundColor
The Background Color of dialog window.
.PARAMETER BorderColor
The Color for dialog window border.
.PARAMETER ButtonBackgroundColor
The Background Color for Buttons in dialog window.
.PARAMETER ButtonForegroundColor
The Foreground Color for Buttons in dialog window.
.PARAMETER ShadowColor
The Color used when creating the Drop-down Shadow effect for dialog window.
.PARAMETER LogoColor
The Color of WinUtil Text found next to WinUtil's Logo inside dialog window.
.PARAMETER LinkForegroundColor
The Foreground Color for Links inside dialog window.
.PARAMETER LinkHoverForegroundColor
The Foreground Color for Links when the mouse pointer hovers over them inside dialog window.
.PARAMETER EnableScroll
A flag indicating whether to enable scrolling if the content exceeds the window size.
.EXAMPLE
Show-CustomDialog -Message "This is a custom dialog with a message and an image above." -Width 300 -Height 200
Show-CustomDialog -Title "My Custom Dialog" -Message "This is a custom dialog with a message and an image above." -Width 300 -Height 200
Makes a new Custom Dialog with the title 'My Custom Dialog' and a message 'This is a custom dialog with a message and an image above.', with dimensions of 300 by 200 pixels.
Other styling options are grabbed from '$sync.Form.Resources' global variable.
.EXAMPLE
$foregroundColor = New-Object System.Windows.Media.SolidColorBrush("#0088e5")
$backgroundColor = New-Object System.Windows.Media.SolidColorBrush("#1e1e1e")
$linkForegroundColor = New-Object System.Windows.Media.SolidColorBrush("#0088e5")
$linkHoverForegroundColor = New-Object System.Windows.Media.SolidColorBrush("#005289")
Show-CustomDialog -Title "My Custom Dialog" -Message "This is a custom dialog with a message and an image above." -Width 300 -Height 200 -ForegroundColor $foregroundColor -BackgroundColor $backgroundColor -LinkForegroundColor $linkForegroundColor -LinkHoverForegroundColor $linkHoverForegroundColor
Makes a new Custom Dialog with the title 'My Custom Dialog' and a message 'This is a custom dialog with a message and an image above.', with dimensions of 300 by 200 pixels, with a link foreground (and general foreground) colors of '#0088e5', background color of '#1e1e1e', and Link Color on Hover of '005289', all of which are in Hexadecimal (the '#' Symbol is required by SolidColorBrush Constructor).
Other styling options are grabbed from '$sync.Form.Resources' global variable.
#>
param(
[string]$Title,
[string]$Message,
[int]$Width = $sync.Form.Resources.CustomDialogWidth,
[int]$Height = $sync.Form.Resources.CustomDialogHeight,
[System.Windows.Media.FontFamily]$FontFamily = $sync.Form.Resources.FontFamily,
[int]$FontSize = $sync.Form.Resources.CustomDialogFontSize,
[int]$HeaderFontSize = $sync.Form.Resources.CustomDialogFontSizeHeader,
[int]$IconSize = $sync.Form.Resources.CustomDialogLogoSize,
[int]$LogoSize = $sync.Form.Resources.CustomDialogLogoSize,
[System.Windows.Media.Color]$ShadowColor = "#AAAAAAAA",
[System.Windows.Media.SolidColorBrush]$LogoColor = $sync.Form.Resources.LabelboxForegroundColor,
[System.Windows.Media.SolidColorBrush]$BorderColor = $sync.Form.Resources.BorderColor,
[System.Windows.Media.SolidColorBrush]$ForegroundColor = $sync.Form.Resources.MainForegroundColor,
[System.Windows.Media.SolidColorBrush]$BackgroundColor = $sync.Form.Resources.MainBackgroundColor,
[System.Windows.Media.SolidColorBrush]$ButtonForegroundColor = $sync.Form.Resources.ButtonInstallForegroundColor,
[System.Windows.Media.SolidColorBrush]$ButtonBackgroundColor = $sync.Form.Resources.ButtonInstallBackgroundColor,
[System.Windows.Media.SolidColorBrush]$LinkForegroundColor = $sync.Form.Resources.LinkForegroundColor,
[System.Windows.Media.SolidColorBrush]$LinkHoverForegroundColor = $sync.Form.Resources.LinkHoverForegroundColor,
[bool]$EnableScroll = $false
)
Add-Type -AssemblyName PresentationFramework
# Define theme colors
$foregroundColor = $sync.Form.Resources.MainForegroundColor
$backgroundColor = $sync.Form.Resources.MainBackgroundColor
$font = New-Object Windows.Media.FontFamily("Consolas")
$borderColor = $sync.Form.Resources.BorderColor # ButtonInstallBackgroundColor
$buttonBackgroundColor = $sync.Form.Resources.ButtonInstallBackgroundColor
$buttonForegroundColor = $sync.Form.Resources.ButtonInstallForegroundColor
$shadowColor = [Windows.Media.ColorConverter]::ConvertFromString("#AAAAAAAA")
$logocolor = $sync.Form.Resources.LabelboxForegroundColor
# Create a custom dialog window
$dialog = New-Object Windows.Window
$dialog.Title = "About"
$dialog.Title = $Title
$dialog.Height = $Height
$dialog.Width = $Width
$dialog.Margin = New-Object Windows.Thickness(10) # Add margin to the entire dialog box
$dialog.WindowStyle = [Windows.WindowStyle]::None # Remove title bar and window controls
$dialog.ResizeMode = [Windows.ResizeMode]::NoResize # Disable resizing
$dialog.WindowStartupLocation = [Windows.WindowStartupLocation]::CenterScreen # Center the window
$dialog.Foreground = $foregroundColor
$dialog.Background = $backgroundColor
$dialog.FontFamily = $font
$dialog.Foreground = $ForegroundColor
$dialog.Background = $BackgroundColor
$dialog.FontFamily = $FontFamily
$dialog.FontSize = $FontSize
# Create a Border for the green edge with rounded corners
$border = New-Object Windows.Controls.Border
$border.BorderBrush = $borderColor
$border.BorderBrush = $BorderColor
$border.BorderThickness = New-Object Windows.Thickness(1) # Adjust border thickness as needed
$border.CornerRadius = New-Object Windows.CornerRadius(10) # Adjust the radius for rounded corners
@ -89,7 +134,7 @@ function Show-CustomDialog {
$grid = New-Object Windows.Controls.Grid
$border.Child = $grid
# Add the following line to show gridlines
# Uncomment the following line to show gridlines
#$grid.ShowGridLines = $true
# Add the following line to set the background color of the grid
@ -102,7 +147,6 @@ function Show-CustomDialog {
$border.HorizontalAlignment = [Windows.HorizontalAlignment]::Stretch
$border.VerticalAlignment = [Windows.VerticalAlignment]::Stretch
# Set up Row Definitions
$row0 = New-Object Windows.Controls.RowDefinition
$row0.Height = [Windows.GridLength]::Auto
@ -129,17 +173,18 @@ function Show-CustomDialog {
[Windows.Controls.Grid]::SetRow($stackPanel, 0) # Set the row to the second row (0-based index)
# Add SVG path to the stack panel
$stackPanel.Children.Add((Invoke-WinUtilAssets -Type "logo" -Size 25))
$stackPanel.Children.Add((Invoke-WinUtilAssets -Type "logo" -Size $LogoSize))
# Add "Winutil" text
$winutilTextBlock = New-Object Windows.Controls.TextBlock
$winutilTextBlock.Text = "Winutil"
$winutilTextBlock.FontSize = $HeaderFontSize
$winutilTextBlock.Foreground = $logocolor
$winutilTextBlock.Foreground = $LogoColor
$winutilTextBlock.Margin = New-Object Windows.Thickness(10, 10, 10, 5) # Add margins around the text block
$stackPanel.Children.Add($winutilTextBlock)
# Add TextBlock for information with text wrapping and margins
$messageTextBlock = New-Object Windows.Controls.TextBlock
$messageTextBlock.FontSize = $FontSize
$messageTextBlock.TextWrapping = [Windows.TextWrapping]::Wrap # Enable text wrapping
$messageTextBlock.HorizontalAlignment = [Windows.HorizontalAlignment]::Left
$messageTextBlock.VerticalAlignment = [Windows.VerticalAlignment]::Top
@ -162,7 +207,7 @@ function Show-CustomDialog {
$hyperlink.NavigateUri = New-Object System.Uri($match.Groups[1].Value)
$hyperlink.Inlines.Add($match.Groups[2].Value)
$hyperlink.TextDecorations = [Windows.TextDecorations]::None # Remove underline
$hyperlink.Foreground = $sync.Form.Resources.LinkForegroundColor
$hyperlink.Foreground = $LinkForegroundColor
$hyperlink.Add_Click({
param($sender, $args)
@ -170,11 +215,15 @@ function Show-CustomDialog {
})
$hyperlink.Add_MouseEnter({
param($sender, $args)
$sender.Foreground = $sync.Form.Resources.LinkHoverForegroundColor
$sender.Foreground = $LinkHoverForegroundColor
$sender.FontSize = ($FontSize + ($FontSize / 4))
$sender.FontWeight = "SemiBold"
})
$hyperlink.Add_MouseLeave({
param($sender, $args)
$sender.Foreground = $sync.Form.Resources.LinkForegroundColor
$sender.Foreground = $LinkForegroundColor
$sender.FontSize = $FontSize
$sender.FontWeight = "Normal"
})
$messageTextBlock.Inlines.Add($hyperlink)
@ -218,7 +267,7 @@ function Show-CustomDialog {
$okButton.Margin = New-Object Windows.Thickness(0, 0, 0, 10)
$okButton.Background = $buttonBackgroundColor
$okButton.Foreground = $buttonForegroundColor
$okButton.BorderBrush = $borderColor
$okButton.BorderBrush = $BorderColor
$okButton.Add_Click({
$dialog.Close()
})

View File

@ -43,7 +43,7 @@ function Invoke-WPFButton {
"WPFPanelprinter" {Invoke-WPFControlPanel -Panel $button}
"WPFPanelsystem" {Invoke-WPFControlPanel -Panel $button}
"WPFPaneluser" {Invoke-WPFControlPanel -Panel $button}
"WPFUpdatesdefault" {Invoke-WPFUpdatesdefault}
"WPFUpdatesdefault" {Invoke-WPFFixesUpdate}
"WPFFixesUpdate" {Invoke-WPFFixesUpdate}
"WPFFixesWinget" {Invoke-WPFFixesWinget}
"WPFRunAdobeCCCleanerTool" {Invoke-WPFRunAdobeCCCleanerTool}

View File

@ -187,9 +187,9 @@ function Invoke-WPFFixesUpdate {
# Reset the Security Descriptors on the Windows Update Services
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Resetting the WU Service Security Descriptors..." -PercentComplete 25
Write-Progress -Id 4 -ParentId 0 -Activity "Resetting the WU Service Security Descriptors" -Status "Resetting the BITS Security Descriptor..." -PercentComplete 0
Start-Process -NoNewWindow -FilePath "sc.exe" -ArgumentList "sdset", "bits", "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)"
Start-Process -NoNewWindow -FilePath "sc.exe" -ArgumentList "sdset", "bits", "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)" -Wait
Write-Progress -Id 4 -ParentId 0 -Activity "Resetting the WU Service Security Descriptors" -Status "Resetting the wuauserv Security Descriptor..." -PercentComplete 50
Start-Process -NoNewWindow -FilePath "sc.exe" -ArgumentList "sdset", "wuauserv", "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)"
Start-Process -NoNewWindow -FilePath "sc.exe" -ArgumentList "sdset", "wuauserv", "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)" -Wait
Write-Progress -Id 4 -ParentId 0 -Activity "Resetting the WU Service Security Descriptors" -Status "Completed" -PercentComplete 100
}
@ -221,19 +221,53 @@ function Invoke-WPFFixesUpdate {
if (Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate") {
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Removing WSUS client settings..." -PercentComplete 60
Write-Progress -Id 6 -ParentId 0 -Activity "Removing WSUS client settings" -PercentComplete 0
Start-Process -NoNewWindow -FilePath "REG" -ArgumentList "DELETE", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate", "/v", "AccountDomainSid", "/f" -RedirectStandardError $true
Start-Process -NoNewWindow -FilePath "REG" -ArgumentList "DELETE", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate", "/v", "PingID", "/f" -RedirectStandardError $true
Start-Process -NoNewWindow -FilePath "REG" -ArgumentList "DELETE", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate", "/v", "SusClientId", "/f" -RedirectStandardError $true
Start-Process -NoNewWindow -FilePath "REG" -ArgumentList "DELETE", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate", "/v", "AccountDomainSid", "/f" -RedirectStandardError "NUL"
Start-Process -NoNewWindow -FilePath "REG" -ArgumentList "DELETE", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate", "/v", "PingID", "/f" -RedirectStandardError "NUL"
Start-Process -NoNewWindow -FilePath "REG" -ArgumentList "DELETE", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate", "/v", "SusClientId", "/f" -RedirectStandardError "NUL"
Write-Progress -Id 6 -ParentId 0 -Activity "Removing WSUS client settings" -Status "Completed" -PercentComplete 100
}
# Remove Group Policy Windows Update settings
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Removing Group Policy Windows Update settings..." -PercentComplete 60
Write-Progress -Id 7 -ParentId 0 -Activity "Removing Group Policy Windows Update settings" -PercentComplete 0
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "ExcludeWUDriversInQualityUpdate" -ErrorAction SilentlyContinue
Write-Host "Defaulting driver offering through Windows Update..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Name "PreventDeviceMetadataFromNetwork" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontPromptForWindowsUpdate" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontSearchWindowsUpdate" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DriverUpdateWizardWuSearchEnabled" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "ExcludeWUDriversInQualityUpdate" -ErrorAction SilentlyContinue
Write-Host "Defaulting Windows Update automatic restart..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "NoAutoRebootWithLoggedOnUsers" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "AUPowerManagement" -ErrorAction SilentlyContinue
Write-Host "Clearing ANY Windows Update Policy settings..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "BranchReadinessLevel" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferFeatureUpdatesPeriodInDays" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferQualityUpdatesPeriodInDays" -ErrorAction SilentlyContinue
Remove-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "HKCU:\Software\Microsoft\WindowsSelfHost" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "HKCU:\Software\Policies" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "HKLM:\Software\Microsoft\Policies" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "HKLM:\Software\Microsoft\WindowsSelfHost" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "HKLM:\Software\Policies" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "HKLM:\Software\WOW6432Node\Microsoft\Policies" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Policies" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" -Recurse -Force -ErrorAction SilentlyContinue
Start-Process -NoNewWindow -FilePath "secedit" -ArgumentList "/configure", "/cfg", "$env:windir\inf\defltbase.inf", "/db", "defltbase.sdb", "/verbose" -Wait
Start-Process -NoNewWindow -FilePath "cmd.exe" -ArgumentList "/c RD /S /Q $env:WinDir\System32\GroupPolicyUsers" -Wait
Start-Process -NoNewWindow -FilePath "cmd.exe" -ArgumentList "/c RD /S /Q $env:WinDir\System32\GroupPolicy" -Wait
Start-Process -NoNewWindow -FilePath "gpupdate" -ArgumentList "/force" -Wait
Write-Progress -Id 7 -ParentId 0 -Activity "Removing Group Policy Windows Update settings" -Status "Completed" -PercentComplete 100
# Reset WinSock
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Resetting WinSock..." -PercentComplete 65
Write-Progress -Id 7 -ParentId 0 -Activity "Resetting WinSock" -Status "Resetting WinSock..." -PercentComplete 0
Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "winsock", "reset" -RedirectStandardOutput $true
Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "winhttp", "reset", "proxy" -RedirectStandardOutput $true
Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "int", "ip", "reset" -RedirectStandardOutput $true
Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "winsock", "reset"
Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "winhttp", "reset", "proxy"
Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "int", "ip", "reset"
Write-Progress -Id 7 -ParentId 0 -Activity "Resetting WinSock" -Status "Completed" -PercentComplete 100
@ -262,7 +296,11 @@ function Invoke-WPFFixesUpdate {
# Force Windows Update to check for updates
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Forcing discovery..." -PercentComplete 95
Write-Progress -Id 10 -ParentId 0 -Activity "Forcing discovery" -Status "Forcing discovery..." -PercentComplete 0
(New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()
try {
(New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()
} catch {
Write-Warning "Failed to create Windows Update COM object: $_"
}
Start-Process -NoNewWindow -FilePath "wuauclt" -ArgumentList "/resetauthorization", "/detectnow"
Write-Progress -Id 10 -ParentId 0 -Activity "Forcing discovery" -Status "Completed" -PercentComplete 100
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Completed" -PercentComplete 100
@ -284,7 +322,7 @@ function Invoke-WPFFixesUpdate {
Write-Progress -Id 3 -Activity "Renaming/Removing Files" -Completed
Write-Progress -Id 4 -Activity "Resetting the WU Service Security Descriptors" -Completed
Write-Progress -Id 5 -Activity "Reregistering DLLs" -Completed
Write-Progress -Id 6 -Activity "Removing WSUS client settings" -Completed
Write-Progress -Id 6 -Activity "Removing Group Policy Windows Update settings" -Completed
Write-Progress -Id 7 -Activity "Resetting WinSock" -Completed
Write-Progress -Id 8 -Activity "Deleting BITS jobs" -Completed
Write-Progress -Id 9 -Activity "Starting Windows Update Services" -Completed

View File

@ -0,0 +1,54 @@
function Invoke-WPFPopup {
param (
[ValidateSet("Show", "Hide", "Toggle")]
[string]$Action = "",
[string[]]$Popups = @(),
[ValidateScript({
$invalid = $_.GetEnumerator() | Where-Object { $_.Value -notin @("Show", "Hide", "Toggle") }
if ($invalid) {
throw "Found invalid Popup-Action pair(s): " + ($invalid | ForEach-Object { "$($_.Key) = $($_.Value)" } -join "; ")
}
$true
})]
[hashtable]$PopupActionTable = @{}
)
if (-not $PopupActionTable.Count -and (-not $Action -or -not $Popups.Count)) {
throw "Provide either 'PopupActionTable' or both 'Action' and 'Popups'."
}
if ($PopupActionTable.Count -and ($Action -or $Popups.Count)) {
throw "Use 'PopupActionTable' on its own, or 'Action' with 'Popups'."
}
# Collect popups and actions
$PopupsToProcess = if ($PopupActionTable.Count) {
$PopupActionTable.GetEnumerator() | ForEach-Object { [PSCustomObject]@{ Name = "$($_.Key)Popup"; Action = $_.Value } }
} else {
$Popups | ForEach-Object { [PSCustomObject]@{ Name = "$_`Popup"; Action = $Action } }
}
$PopupsNotFound = @()
# Apply actions
foreach ($popupEntry in $PopupsToProcess) {
$popupName = $popupEntry.Name
if (-not $sync.$popupName) {
$PopupsNotFound += $popupName
continue
}
$sync.$popupName.IsOpen = switch ($popupEntry.Action) {
"Show" { $true }
"Hide" { $false }
"Toggle" { -not $sync.$popupName.IsOpen }
}
}
if ($PopupsNotFound.Count -gt 0) {
throw "Could not find the following popups: $($PopupsNotFound -join ', ')"
}
}

View File

@ -1,39 +0,0 @@
function Invoke-WPFToggle {
<#
.SYNOPSIS
Invokes the scriptblock for the given toggle
.PARAMETER Button
The name of the toggle to invoke
#>
Param ([string]$Button)
# Use this to get the name of the button
#[System.Windows.MessageBox]::Show("$Button","Chris Titus Tech's Windows Utility","OK","Info")
$ToggleStatus = (Get-WinUtilToggleStatus $Button)
Switch -Wildcard ($Button) {
"WPFToggleDarkMode" {Invoke-WinUtilDarkMode $ToggleStatus}
"WPFToggleBingSearch" {Invoke-WinUtilBingSearch $ToggleStatus}
"WPFToggleNumLock" {Invoke-WinUtilNumLock $ToggleStatus}
"WPFToggleVerboseLogon" {Invoke-WinUtilVerboseLogon $ToggleStatus}
"WPFToggleShowExt" {Invoke-WinUtilShowExt $ToggleStatus}
"WPFToggleSnapWindow" {Invoke-WinUtilSnapWindow $ToggleStatus}
"WPFToggleSnapFlyout" {Invoke-WinUtilSnapFlyout $ToggleStatus}
"WPFToggleSnapSuggestion" {Invoke-WinUtilSnapSuggestion $ToggleStatus}
"WPFToggleMouseAcceleration" {Invoke-WinUtilMouseAcceleration $ToggleStatus}
"WPFToggleStickyKeys" {Invoke-WinUtilStickyKeys $ToggleStatus}
"WPFToggleTaskbarWidgets" {Invoke-WinUtilTaskbarWidgets $ToggleStatus}
"WPFToggleTaskbarSearch" {Invoke-WinUtilTaskbarSearch $ToggleStatus}
"WPFToggleTaskView" {Invoke-WinUtilTaskView $ToggleStatus}
"WPFToggleHiddenFiles" {Invoke-WinUtilHiddenFiles $ToggleStatus}
"WPFToggleTaskbarAlignment" {Invoke-WinUtilTaskbarAlignment $ToggleStatus}
"WPFToggleDetailedBSoD" {Invoke-WinUtilDetailedBSoD $ToggleStatus}
}
}

View File

@ -98,6 +98,7 @@ function Invoke-WPFUIElements {
$entrycount = $configHashtable.Keys.Count + $organizedData["0"].Keys.Count
$maxcount = [Math]::Round($entrycount / $columncount + 0.5)
}
}
# Iterate through 'organizedData' by panel, category, and application
@ -105,7 +106,7 @@ function Invoke-WPFUIElements {
foreach ($panelKey in ($organizedData.Keys | Sort-Object)) {
# Create a Border for each column
$border = New-Object Windows.Controls.Border
$border.VerticalAlignment = "Stretch" # Ensure the border stretches vertically
$border.VerticalAlignment = "Stretch"
[System.Windows.Controls.Grid]::SetColumn($border, $panelcount)
$border.style = $borderstyle
$targetGrid.Children.Add($border) | Out-Null
@ -114,10 +115,20 @@ function Invoke-WPFUIElements {
$stackPanel = New-Object Windows.Controls.StackPanel
$stackPanel.Background = [Windows.Media.Brushes]::Transparent
$stackPanel.SnapsToDevicePixels = $true
$stackPanel.VerticalAlignment = "Stretch" # Ensure the stack panel stretches vertically
$stackPanel.VerticalAlignment = "Stretch"
$border.Child = $stackPanel
$panelcount++
# Add Windows Version label if this is the updates panel
if ($targetGridName -eq "updatespanel") {
$windowsVersion = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").ProductName
$versionLabel = New-Object Windows.Controls.Label
$versionLabel.Content = "Windows Version: $windowsVersion"
$versionLabel.FontSize = $theme.FontSize
$versionLabel.HorizontalAlignment = "Left"
$stackPanel.Children.Add($versionLabel) | Out-Null
}
foreach ($category in ($organizedData[$panelKey].Keys | Sort-Object)) {
$count++
if ($targetGridName -eq "appspanel" -and $columncount -gt 0) {
@ -125,7 +136,7 @@ function Invoke-WPFUIElements {
if ($panelcount -eq $panelcount2) {
# Create a new Border for the new column
$border = New-Object Windows.Controls.Border
$border.VerticalAlignment = "Stretch" # Ensure the border stretches vertically
$border.VerticalAlignment = "Stretch"
[System.Windows.Controls.Grid]::SetColumn($border, $panelcount)
$border.style = $borderstyle
$targetGrid.Children.Add($border) | Out-Null
@ -134,7 +145,7 @@ function Invoke-WPFUIElements {
$stackPanel = New-Object Windows.Controls.StackPanel
$stackPanel.Background = [Windows.Media.Brushes]::Transparent
$stackPanel.SnapsToDevicePixels = $true
$stackPanel.VerticalAlignment = "Stretch" # Ensure the stack panel stretches vertically
$stackPanel.VerticalAlignment = "Stretch"
$border.Child = $stackPanel
$panelcount++
}
@ -142,7 +153,7 @@ function Invoke-WPFUIElements {
$label = New-Object Windows.Controls.Label
$label.Content = $category -replace ".*__", ""
$label.FontSize = $theme.FontSizeHeading
$label.FontSize = $theme.HeadingFontSize
$label.FontFamily = $theme.HeaderFontFamily
$stackPanel.Children.Add($label) | Out-Null
@ -157,7 +168,7 @@ function Invoke-WPFUIElements {
if ($panelcount -eq $panelcount2) {
# Create a new Border for the new column
$border = New-Object Windows.Controls.Border
$border.VerticalAlignment = "Stretch" # Ensure the border stretches vertically
$border.VerticalAlignment = "Stretch"
[System.Windows.Controls.Grid]::SetColumn($border, $panelcount)
$border.style = $borderstyle
$targetGrid.Children.Add($border) | Out-Null
@ -166,7 +177,7 @@ function Invoke-WPFUIElements {
$stackPanel = New-Object Windows.Controls.StackPanel
$stackPanel.Background = [Windows.Media.Brushes]::Transparent
$stackPanel.SnapsToDevicePixels = $true
$stackPanel.VerticalAlignment = "Stretch" # Ensure the stack panel stretches vertically
$stackPanel.VerticalAlignment = "Stretch"
$border.Child = $stackPanel
$panelcount++
}
@ -192,11 +203,16 @@ function Invoke-WPFUIElements {
$sync[$entryInfo.Name] = $checkBox
$sync[$entryInfo.Name].IsChecked = Get-WinUtilToggleStatus $sync[$entryInfo.Name].Name
$sync[$entryInfo.Name].IsChecked = (Get-WinUtilToggleStatus $entryInfo.Name)
$sync[$entryInfo.Name].Add_Click({
$sync[$entryInfo.Name].Add_Checked({
[System.Object]$Sender = $args[0]
Invoke-WPFToggle $Sender.name
Invoke-WinUtilTweaks $sender.name
})
$sync[$entryInfo.Name].Add_Unchecked({
[System.Object]$Sender = $args[0]
Invoke-WinUtiltweaks $sender.name -undo $true
})
}

View File

@ -31,23 +31,20 @@ $sync.runspace.Open()
# Create classes for different exceptions
class WingetFailedInstall : Exception {
[string]$additionalData
class WingetFailedInstall : Exception {
[string]$additionalData
WingetFailedInstall($Message) : base($Message) {}
}
WingetFailedInstall($Message) : base($Message) {}
}
class ChocoFailedInstall : Exception {
[string]$additionalData
ChocoFailedInstall($Message) : base($Message) {}
}
class ChocoFailedInstall : Exception {
[string]$additionalData
ChocoFailedInstall($Message) : base($Message) {}
}
class GenericException : Exception {
[string]$additionalData
GenericException($Message) : base($Message) {}
}
class GenericException : Exception {
[string]$additionalData
GenericException($Message) : base($Message) {}
}
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
@ -115,6 +112,8 @@ Invoke-WinutilThemeChange -init $true
Invoke-WPFUIElements -configVariable $sync.configs.applications -targetGridName "appspanel" -columncount 5
Invoke-WPFUIElements -configVariable $sync.configs.tweaks -targetGridName "tweakspanel" -columncount 2
Invoke-WPFUIElements -configVariable $sync.configs.feature -targetGridName "featurespanel" -columncount 2
# Future implementation: Add Windows Version to updates panel
#Invoke-WPFUIElements -configVariable $sync.configs.updates -targetGridName "updatespanel" -columncount 1
#===========================================================================
# Store Form Objects In PowerShell
@ -254,12 +253,7 @@ $commonKeyEvents = {
$sync["Form"].Add_PreViewKeyDown($commonKeyEvents)
$sync["Form"].Add_MouseLeftButtonDown({
# Hide Settings and Theme Popup on click anywhere else
if ($sync.SettingsButton.IsOpen -or
$sync.ThemePopup.IsOpen) {
$sync.SettingsPopup.IsOpen = $false
$sync.ThemePopup.IsOpen = $false
}
Invoke-WPFPopup -Action "Hide" -Popups @("Settings", "Theme")
$sync["Form"].DragMove()
})
@ -277,12 +271,7 @@ $sync["Form"].Add_MouseDoubleClick({
$sync["Form"].Add_Deactivated({
Write-Debug "WinUtil lost focus"
# Hide Settings and Theme Popup on Winutil Focus Loss
if ($sync.SettingsButton.IsOpen -or
$sync.ThemePopup.IsOpen) {
$sync.SettingsPopup.IsOpen = $false
$sync.ThemePopup.IsOpen = $false
}
Invoke-WPFPopup -Action "Hide" -Popups @("Settings", "Theme")
})
$sync["Form"].Add_ContentRendered({
@ -521,101 +510,79 @@ Set-WinUtilTaskbaritem -overlay "logo"
$sync["Form"].Add_Activated({
Set-WinUtilTaskbaritem -overlay "logo"
})
# Define event handler for ThemeButton click
$sync["ThemeButton"].Add_Click({
if ($sync.ThemePopup.IsOpen) {
$sync.ThemePopup.IsOpen = $false
}
else{
$sync.ThemePopup.IsOpen = $true
}
$sync.SettingsPopup.IsOpen = $false
})
# Define event handlers for menu items
$sync["ThemeButton"].Add_Click({
Write-Debug "ThemeButton clicked"
Invoke-WPFPopup -PopupActionTable @{ "Settings" = "Hide"; "Theme" = "Toggle" }
$_.Handled = $false
})
$sync["AutoThemeMenuItem"].Add_Click({
$sync.ThemePopup.IsOpen = $false
Write-Debug "About clicked"
Invoke-WPFPopup -Action "Hide" -Popups @("Theme")
Invoke-WinutilThemeChange -theme "Auto"
$_.Handled = $false
})
# Define event handlers for menu items
})
$sync["DarkThemeMenuItem"].Add_Click({
$sync.ThemePopup.IsOpen = $false
Write-Debug "Dark Theme clicked"
Invoke-WPFPopup -Action "Hide" -Popups @("Theme")
Invoke-WinutilThemeChange -theme "Dark"
$_.Handled = $false
})
# Define event handlers for menu items
})
$sync["LightThemeMenuItem"].Add_Click({
$sync.ThemePopup.IsOpen = $false
Write-Debug "Light Theme clicked"
Invoke-WPFPopup -Action "Hide" -Popups @("Theme")
Invoke-WinutilThemeChange -theme "Light"
$_.Handled = $false
})
})
# Define event handler for button click
$sync["SettingsButton"].Add_Click({
Write-Debug "SettingsButton clicked"
if ($sync.SettingsPopup.IsOpen) {
$sync.SettingsPopup.IsOpen = $false
}
else{
$sync.SettingsPopup.IsOpen = $true
}
$sync.ThemePopup.IsOpen = $false
Invoke-WPFPopup -PopupActionTable @{ "Settings" = "Toggle"; "Theme" = "Hide" }
$_.Handled = $false
})
# Define event handlers for menu items
$sync["ImportMenuItem"].Add_Click({
# Handle Import menu item click
Write-Debug "Import clicked"
$sync["SettingsPopup"].IsOpen = $false
Invoke-WPFImpex -type "import"
$_.Handled = $false
Write-Debug "Import clicked"
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
Invoke-WPFImpex -type "import"
$_.Handled = $false
})
$sync["ExportMenuItem"].Add_Click({
# Handle Export menu item click
Write-Debug "Export clicked"
$sync["SettingsPopup"].IsOpen = $false
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
Invoke-WPFImpex -type "export"
$_.Handled = $false
})
$sync["AboutMenuItem"].Add_Click({
# Handle Export menu item click
Write-Debug "About clicked"
$sync["SettingsPopup"].IsOpen = $false
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
$authorInfo = @"
Author : <a href="https://github.com/ChrisTitusTech">@christitustech</a>
Runspace : <a href="https://github.com/DeveloperDurp">@DeveloperDurp</a>
MicroWin : <a href="https://github.com/KonTy">@KonTy</a>
MicroWin : <a href="https://github.com/KonTy">@KonTy</a>, <a href="https://github.com/CodingWonders">@CodingWonders</a>
GitHub : <a href="https://github.com/ChrisTitusTech/winutil">ChrisTitusTech/winutil</a>
Version : <a href="https://github.com/ChrisTitusTech/winutil/releases/tag/$($sync.version)">$($sync.version)</a>
"@
Show-CustomDialog -Message $authorInfo -LogoSize $LogoSize
Show-CustomDialog -Title "About" -Message $authorInfo
})
$sync["SponsorMenuItem"].Add_Click({
# Handle Export menu item click
Write-Debug "Sponsors clicked"
$sync["SettingsPopup"].IsOpen = $false
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
$authorInfo = @"
<a href="https://github.com/sponsors/ChrisTitusTech">Current sponsors for ChrisTitusTech:</a>
"@
$authorInfo += "`n"
try {
# Call the function to get the sponsors
$sponsors = Invoke-WinUtilSponsors
# Append the sponsors to the authorInfo
$sponsors | ForEach-Object { $authorInfo += "$_`n" }
foreach ($sponsor in $sponsors) {
$authorInfo += "<a href=`"https://github.com/sponsors/ChrisTitusTech`">$sponsor</a>`n"
}
} catch {
$authorInfo += "An error occurred while fetching or processing the sponsors: $_`n"
}
Show-CustomDialog -Message $authorInfo -EnableScroll $true
Show-CustomDialog -Title "Sponsors" -Message $authorInfo -EnableScroll $true
})
$sync["Form"].ShowDialog() | out-null

View File

@ -1,925 +0,0 @@
<#PSScriptInfo
.VERSION 3.0.1
.GUID 3b581edb-5d90-4fa1-ba15-4f2377275463
.AUTHOR asheroto, 1ckov, MisterZeus, ChrisTitusTech
.COMPANYNAME asheroto
.TAGS PowerShell Windows winget win get install installer fix script setup
.PROJECTURI https://github.com/asheroto/winget-install
.RELEASENOTES
[Version 0.0.1] - Initial Release.
[Version 0.0.2] - Implemented function to get the latest version of winget and its license.
[Version 0.0.3] - Signed file for PSGallery.
[Version 0.0.4] - Changed URI to grab latest release instead of releases and preleases.
[Version 0.0.5] - Updated version number of dependencies.
[Version 1.0.0] - Major refactor code, see release notes for more information.
[Version 1.0.1] - Fixed minor bug where version 2.8 was hardcoded in URL.
[Version 1.0.2] - Hardcoded UI Xaml version 2.8.4 as a failsafe in case the API fails. Added CheckForUpdates, Version, Help functions. Various bug fixes.
[Version 1.0.3] - Added error message to catch block. Fixed bug where appx package was not being installed.
[Version 1.0.4] - MisterZeus optimized code for readability.
[Version 2.0.0] - Major refactor. Reverted to UI.Xaml 2.7.3 for stability. Adjusted script to fix install issues due to winget changes (thank you ChrisTitusTech). Added in all architecture support.
[Version 2.0.1] - Renamed repo and URL references from winget-installer to winget-install. Added extra space after the last line of output.
[Version 2.0.2] - Adjusted CheckForUpdates to include Install-Script instructions and extra spacing.
[Version 2.1.0] - Added alternate method/URL for dependencies in case the main URL is down. Fixed licensing issue when winget is installed on Server 2022.
[Version 2.1.1] - Switched primary/alternate methods. Added Cleanup function to avoid errors when cleaning up temp files. Added output of URL for alternate method. Suppressed Add-AppxProvisionedPackage output. Improved success message. Improved verbiage. Improve PS script comments. Added check if the URL is empty. Moved display of URL beneath the check.
[Version 3.0.0] - Major changes. Added OS version detection checks - detects OS version, release ID, ensures compatibility. Forces older file installation for Server 2022 to avoid issues after installing. Added DebugMode, DisableCleanup, Force. Renamed CheckForUpdates to CheckForUpdate. Improved output. Improved error handling. Improved comments. Improved code readability. Moved CheckForUpdate into function. Added PowerShellGalleryName. Renamed Get-OSVersion to Get-OSInfo. Moved architecture detection into Get-OSInfo. Renamed Get-NewestLink to Get-WingetDownloadUrl. Have Get-WingetDownloadUrl not get preview releases.
[Version 3.0.1] - Updated Get-OSInfo function to fix issues when used on non-English systems. Improved error handling of "resources in use" error.
#>
<#
.SYNOPSIS
Downloads and installs the latest version of winget and its dependencies. Updates the PATH variable if needed.
.DESCRIPTION
Downloads and installs the latest version of winget and its dependencies. Updates the PATH variable if needed.
This script is designed to be straightforward and easy to use, removing the hassle of manually downloading, installing, and configuring winget. To make the newly installed winget available for use, a system reboot may be required after running the script.
This function should be run with administrative privileges.
.EXAMPLE
winget-install
.PARAMETER DebugMode
Enables debug mode, which shows additional information for debugging.
.PARAMETER DisableCleanup
Disables cleanup of the script and prerequisites after installation.
.PARAMETER Force
Ensures installation of winget and its dependencies, even if already present.
.PARAMETER CheckForUpdate
Checks if there is an update available for the script.
.PARAMETER Version
Displays the version of the script.
.PARAMETER Help
Displays the full help information for the script.
.NOTES
Version : 3.0.1
Created by : asheroto
.LINK
Project Site: https://github.com/asheroto/winget-install
#>
[CmdletBinding()]
param (
[switch]$Version,
[switch]$Help,
[switch]$CheckForUpdate,
[switch]$DisableCleanup,
[switch]$DebugMode,
[switch]$Force
)
# Version
$CurrentVersion = '3.0.1'
$RepoOwner = 'asheroto'
$RepoName = 'winget-install'
$PowerShellGalleryName = 'winget-install'
# Versions
$ProgressPreference = 'SilentlyContinue' # Suppress progress bar (makes downloading super fast)
$ConfirmPreference = 'None' # Suppress confirmation prompts
# Display version if -Version is specified
if ($Version.IsPresent) {
$CurrentVersion
exit 0
}
# Display full help if -Help is specified
if ($Help) {
Get-Help -Name $MyInvocation.MyCommand.Source -Full
exit 0
}
# Display $PSVersionTable and Get-Host if -Verbose is specified
if ($PSBoundParameters.ContainsKey('Verbose') -and $PSBoundParameters['Verbose']) {
$PSVersionTable
Get-Host
}
function Get-TempFolder {
<#
.SYNOPSIS
Gets the path of the current user's temp folder.
.DESCRIPTION
This function retrieves the path of the current user's temp folder.
.EXAMPLE
Get-TempFolder
#>
return [System.IO.Path]::GetTempPath()
}
function Get-OSInfo {
<#
.SYNOPSIS
Retrieves detailed information about the operating system version and architecture.
.DESCRIPTION
This function queries both the Windows registry and the Win32_OperatingSystem class to gather comprehensive information about the operating system. It returns details such as the release ID, display version, name, type (Workstation/Server), numeric version, edition ID, version (object that includes major, minor, and build numbers), and architecture (OS architecture, not processor architecture).
.EXAMPLE
Get-OSInfo
This example retrieves the OS version details of the current system and returns an object with properties like ReleaseId, DisplayVersion, Name, Type, NumericVersion, EditionId, Version, and Architecture.
.EXAMPLE
(Get-OSInfo).Version.Major
This example retrieves the major version number of the operating system. The Get-OSInfo function returns an object with a Version property, which itself is an object containing Major, Minor, and Build properties. You can access these sub-properties using dot notation.
.EXAMPLE
$osDetails = Get-OSInfo
Write-Output "OS Name: $($osDetails.Name)"
Write-Output "OS Type: $($osDetails.Type)"
Write-Output "OS Architecture: $($osDetails.Architecture)"
This example stores the result of Get-OSInfo in a variable and then accesses various properties to print details about the operating system.
#>
[CmdletBinding()]
param ()
try {
# Get registry values
$registryValues = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
$releaseIdValue = $registryValues.ReleaseId
$displayVersionValue = $registryValues.DisplayVersion
$nameValue = $registryValues.ProductName
$editionIdValue = $registryValues.EditionId
# Strip out "Server" from the $editionIdValue if it exists
$editionIdValue = $editionIdValue -replace "Server", ""
# Get OS details using Get-CimInstance because the registry key for Name is not always correct with Windows 11
$osDetails = Get-CimInstance -ClassName Win32_OperatingSystem
$nameValue = $osDetails.Caption
# Get architecture details of the OS (not the processor)
# Get only the numbers
$architecture = ($osDetails.OSArchitecture -replace "[^\d]").Trim()
# If 32-bit or 64-bit replace with x32 and x64
if ($architecture -eq "32") {
$architecture = "x32"
} elseif ($architecture -eq "64") {
$architecture = "x64"
}
# Get OS version details (as version object)
$versionValue = [System.Environment]::OSVersion.Version
# Determine product type
# Reference: https://learn.microsoft.com/en-us/dotnet/api/microsoft.powershell.commands.producttype?view=powershellsdk-1.1.0
if ($osDetails.ProductType -eq 1) {
$typeValue = "Workstation"
} elseif ($osDetails.ProductType -eq 2 -or $osDetails.ProductType -eq 3) {
$typeValue = "Server"
} else {
$typeValue = "Unknown"
}
# Extract numerical value from Name
$numericVersion = ($nameValue -replace "[^\d]").Trim()
# Create and return custom object with the required properties
$result = [PSCustomObject]@{
ReleaseId = $releaseIdValue
DisplayVersion = $displayVersionValue
Name = $nameValue
Type = $typeValue
NumericVersion = $numericVersion
EditionId = $editionIdValue
Version = $versionValue
Architecture = $architecture
}
return $result
} catch {
Write-Error "Unable to get OS version details.`nError: $_"
exit 1
}
}
function Get-GitHubRelease {
<#
.SYNOPSIS
Fetches the latest release information of a GitHub repository.
.DESCRIPTION
This function uses the GitHub API to get information about the latest release of a specified repository, including its version and the date it was published.
.PARAMETER Owner
The GitHub username of the repository owner.
.PARAMETER Repo
The name of the repository.
.EXAMPLE
Get-GitHubRelease -Owner "asheroto" -Repo "winget-install"
This command retrieves the latest release version and published datetime of the winget-install repository owned by asheroto.
#>
[CmdletBinding()]
param (
[string]$Owner,
[string]$Repo
)
try {
$url = "https://api.github.com/repos/$Owner/$Repo/releases/latest"
$response = Invoke-RestMethod -Uri $url -ErrorAction Stop
$latestVersion = $response.tag_name
$publishedAt = $response.published_at
# Convert UTC time string to local time
$UtcDateTime = [DateTime]::Parse($publishedAt, [System.Globalization.CultureInfo]::InvariantCulture, [System.Globalization.DateTimeStyles]::RoundtripKind)
$PublishedLocalDateTime = $UtcDateTime.ToLocalTime()
[PSCustomObject]@{
LatestVersion = $latestVersion
PublishedDateTime = $PublishedLocalDateTime
}
} catch {
Write-Error "Unable to check for updates.`nError: $_"
exit 1
}
}
function CheckForUpdate {
param (
[string]$RepoOwner,
[string]$RepoName,
[version]$CurrentVersion,
[string]$PowerShellGalleryName
)
$Data = Get-GitHubRelease -Owner $RepoOwner -Repo $RepoName
if ($Data.LatestVersion -gt $CurrentVersion) {
Write-Output "`nA new version of $RepoName is available.`n"
Write-Output "Current version: $CurrentVersion."
Write-Output "Latest version: $($Data.LatestVersion)."
Write-Output "Published at: $($Data.PublishedDateTime).`n"
Write-Output "You can download the latest version from https://github.com/$RepoOwner/$RepoName/releases`n"
if ($PowerShellGalleryName) {
Write-Output "Or you can run the following command to update:"
Write-Output "Install-Script $PowerShellGalleryName -Force`n"
}
} else {
Write-Output "`n$RepoName is up to date.`n"
Write-Output "Current version: $CurrentVersion."
Write-Output "Latest version: $($Data.LatestVersion)."
Write-Output "Published at: $($Data.PublishedDateTime)."
Write-Output "`nRepository: https://github.com/$RepoOwner/$RepoName/releases`n"
}
exit 0
}
function Write-Section($text) {
<#
.SYNOPSIS
Prints a text block surrounded by a section divider for enhanced output readability.
.DESCRIPTION
This function takes a string input and prints it to the console, surrounded by a section divider made of hash characters.
It is designed to enhance the readability of console output.
.PARAMETER text
The text to be printed within the section divider.
.EXAMPLE
Write-Section "Downloading Files..."
This command prints the text "Downloading Files..." surrounded by a section divider.
#>
Write-Output ""
Write-Output ("#" * ($text.Length + 4))
Write-Output "# $text #"
Write-Output ("#" * ($text.Length + 4))
Write-Output ""
}
function Get-WingetDownloadUrl {
<#
.SYNOPSIS
Retrieves the download URL of the latest release asset that matches a specified pattern from the GitHub repository.
.DESCRIPTION
This function uses the GitHub API to get information about the latest release of the winget-cli repository.
It then retrieves the download URL for the release asset that matches a specified pattern.
.PARAMETER Match
The pattern to match in the asset names.
.EXAMPLE
Get-WingetDownloadUrl "msixbundle"
This command retrieves the download URL for the latest release asset with a name that contains "msixbundle".
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string]$Match
)
$uri = "https://api.github.com/repos/microsoft/winget-cli/releases"
Write-Debug "Getting information from $uri"
$releases = Invoke-RestMethod -uri $uri -Method Get -ErrorAction stop
Write-Debug "Getting latest release..."
foreach ($release in $releases) {
if ($release.name -match "preview") {
continue
}
$data = $release.assets | Where-Object name -Match $Match
if ($data) {
return $data.browser_download_url
}
}
Write-Debug "Falling back to the latest release..."
$latestRelease = $releases | Select-Object -First 1
$data = $latestRelease.assets | Where-Object name -Match $Match
return $data.browser_download_url
}
function Get-WingetStatus {
<#
.SYNOPSIS
Checks if winget is installed.
.DESCRIPTION
This function checks if winget is installed.
.EXAMPLE
Get-WingetStatus
#>
# Check if winget is installed
$winget = Get-Command -Name winget -ErrorAction SilentlyContinue
# If winget is installed, return $true
if ($null -ne $winget) {
return $true
}
# If winget is not installed, return $false
return $false
}
function Update-PathEnvironmentVariable {
<#
.SYNOPSIS
Updates the PATH environment variable with a new path for both the User and Machine levels.
.DESCRIPTION
The function will add a new path to the PATH environment variable, making sure it is not a duplicate.
If the new path is already in the PATH variable, the function will skip adding it.
This function operates at both User and Machine levels.
.PARAMETER NewPath
The new directory path to be added to the PATH environment variable.
.EXAMPLE
Update-PathEnvironmentVariable -NewPath "C:\NewDirectory"
This command will add the directory "C:\NewDirectory" to the PATH variable at both the User and Machine levels.
#>
param(
[string]$NewPath
)
foreach ($Level in "Machine", "User") {
# Get the current PATH variable
$path = [Environment]::GetEnvironmentVariable("PATH", $Level)
# Check if the new path is already in the PATH variable
if (!$path.Contains($NewPath)) {
if ($DebugMode) {
Write-Output "Adding $NewPath to PATH variable for $Level..."
} else {
Write-Output "Adding PATH variable for $Level..."
}
# Add the new path to the PATH variable
$path = ($path + ";" + $NewPath).Split(';') | Select-Object -Unique
$path = $path -join ';'
# Set the new PATH variable
[Environment]::SetEnvironmentVariable("PATH", $path, $Level)
} else {
if ($DebugMode) {
Write-Output "$NewPath already present in PATH variable for $Level, skipping."
} else {
Write-Output "PATH variable already present for $Level, skipping."
}
}
}
}
function Handle-Error {
<#
.SYNOPSIS
Handles common errors that may occur during an installation process.
.DESCRIPTION
This function takes an ErrorRecord object and checks for certain known error codes.
Depending on the error code, it writes appropriate warning messages or throws the error.
.PARAMETER ErrorRecord
The ErrorRecord object that represents the error that was caught. This object contains
information about the error, including the exception that was thrown.
.EXAMPLE
try {
# Some code that may throw an error...
} catch {
Handle-Error $_
}
This example shows how you might use the Handle-Error function in a try-catch block.
If an error occurs in the try block, the catch block catches it and calls Handle-Error,
passing the error (represented by the $_ variable) to the function.
#>
param($ErrorRecord)
# Store current value
$OriginalErrorActionPreference = $ErrorActionPreference
# Set to silently continue
$ErrorActionPreference = 'SilentlyContinue'
if ($ErrorRecord.Exception.Message -match '0x80073D06') {
Write-Warning "Higher version already installed."
Write-Warning "That's okay, continuing..."
} elseif ($ErrorRecord.Exception.Message -match '0x80073CF0') {
Write-Warning "Same version already installed."
Write-Warning "That's okay, continuing..."
} elseif ($ErrorRecord.Exception.Message -match '0x80073D02') {
# Stop execution and return the ErrorRecord so that the calling try/catch block throws the error
Write-Warning "Resources modified are in-use. Try closing Windows Terminal / PowerShell / Command Prompt and try again."
Write-Warning "If the problem persists, restart your computer."
return $ErrorRecord
} elseif ($ErrorRecord.Exception.Message -match 'Unable to connect to the remote server') {
Write-Warning "Cannot connect to the Internet to download the required files."
Write-Warning "Try running the script again and make sure you are connected to the Internet."
Write-Warning "Sometimes the nuget.org server is down, so you may need to try again later."
return $ErrorRecord
} elseif ($ErrorRecord.Exception.Message -match "The remote name could not be resolved") {
Write-Warning "Cannot connect to the Internet to download the required files."
Write-Warning "Try running the script again and make sure you are connected to the Internet."
Write-Warning "Make sure DNS is working correctly on your computer."
} else {
# For other errors, we should stop the execution and return the ErrorRecord so that the calling try/catch block throws the error
return $ErrorRecord
}
# Reset to original value
$ErrorActionPreference = $OriginalErrorActionPreference
}
function Cleanup {
<#
.SYNOPSIS
Deletes a file or directory specified without prompting for confirmation or displaying errors.
.DESCRIPTION
This function takes a path to a file or directory and deletes it without prompting for confirmation or displaying errors.
If the path is a directory, the function will delete the directory and all its contents.
.PARAMETER Path
The path of the file or directory to be deleted.
.PARAMETER Recurse
If the path is a directory, this switch specifies whether to delete the directory and all its contents.
.EXAMPLE
Cleanup -Path "C:\Temp"
This example deletes the directory "C:\Temp" and all its contents.
.EXAMPLE
Cleanup -Path "C:\Temp" -Recurse
This example deletes the directory "C:\Temp" and all its contents.
.EXAMPLE
Cleanup -Path "C:\Temp\file.txt"
This example deletes the file "C:\Temp\file.txt".
#>
param (
[string]$Path,
[switch]$Recurse
)
try {
if (Test-Path -Path $Path) {
if ($Recurse -and (Get-Item -Path $Path) -is [System.IO.DirectoryInfo]) {
Get-ChildItem -Path $Path -Recurse | Remove-Item -Force -Recurse
Remove-Item -Path $Path -Force -Recurse
} else {
Remove-Item -Path $Path -Force
}
}
if ($DebugMode) {
Write-Output "Deleted: $Path"
}
} catch {
# Errors are ignored
}
}
function Install-Prerequisite {
<#
.SYNOPSIS
Downloads and installs a prerequisite for winget.
.DESCRIPTION
This function takes a name, version, URL, alternate URL, content type, and body and downloads and installs the prerequisite.
.PARAMETER Name
The name of the prerequisite.
.PARAMETER Version
The version of the prerequisite.
.PARAMETER Url
The URL of the prerequisite.
.PARAMETER AlternateUrl
The alternate URL of the prerequisite.
.PARAMETER ContentType
The content type of the prerequisite.
.PARAMETER Body
The body of the prerequisite.
.PARAMETER NupkgVersion
The nupkg version of the prerequisite.
.PARAMETER AppxFileVersion
The appx file version of the prerequisite.
.EXAMPLE
Install-Prerequisite -Name "VCLibs" -Version "14.00" -Url "https://store.rg-adguard.net/api/GetFiles" -AlternateUrl "https://aka.ms/Microsoft.VCLibs.$arch.14.00.Desktop.appx" -ContentType "application/x-www-form-urlencoded" -Body "type=PackageFamilyName&url=Microsoft.VCLibs.140.00_8wekyb3d8bbwe&ring=RP&lang=en-US"
Where $arch is the architecture type of the current system.
#>
param (
[string]$Name,
[string]$Url,
[string]$AlternateUrl,
[string]$ContentType,
[string]$Body,
[string]$NupkgVersion,
[string]$AppxFileVersion
)
$osVersion = Get-OSInfo
$arch = $osVersion.Architecture
Write-Section "Downloading & installing ${arch} ${Name}..."
$ThrowReason = @{
Message = ""
Code = 0
}
try {
# ============================================================================ #
# Windows 10 / Server 2022 detection
# ============================================================================ #
# Function to extract domain from URL
function Get-DomainFromUrl($url) {
$uri = [System.Uri]$url
$domain = $uri.Host -replace "^www\."
return $domain
}
# If Server 2022 or Windows 10, force non-store version of VCLibs (return true)
$messageTemplate = "{OS} detected. Using {DOMAIN} version of {NAME}."
# Determine the OS-specific information
$osType = $osVersion.Type
$osNumericVersion = $osVersion.NumericVersion
if (($osType -eq "Server" -and $osNumericVersion -eq 2022) -or ($osType -eq "Workstation" -and $osNumericVersion -eq 10)) {
if ($osType -eq "Server") {
$osName = "Server 2022"
} else {
$osName = "Windows 10"
}
$domain = Get-DomainFromUrl $AlternateUrl
$ThrowReason.Message = ($messageTemplate -replace "{OS}", $osName) -replace "{NAME}", $Name -replace "{DOMAIN}", $domain
$ThrowReason.Code = 1
throw
}
# ============================================================================ #
# Primary method
# ============================================================================ #
$url = Invoke-WebRequest -Uri $Url -Method "POST" -ContentType $ContentType -Body $Body -UseBasicParsing | ForEach-Object Links | Where-Object outerHTML -match "$Name.+_${arch}__8wekyb3d8bbwe.appx" | ForEach-Object href
# If the URL is empty, try the alternate method
if ($url -eq "") {
$ThrowReason.Message = "URL is empty"
$ThrowReason.Code = 2
throw
}
if ($DebugMode) {
Write-Output "URL: ${url}`n"
}
Write-Output "Installing ${arch} ${Name}..."
Add-AppxPackage $url -ErrorAction Stop
Write-Output "`n$Name installed successfully."
} catch {
# Alternate method
if ($_.Exception.Message -match '0x80073D02') {
# If resources in use exception, fail immediately
Handle-Error $_
throw
}
try {
$url = $AlternateUrl
# Throw reason if alternate method is required
if ($ThrowReason.Code -eq 0) {
Write-Warning "Error when trying to download or install $Name. Trying alternate method..."
} else {
Write-Warning $ThrowReason.Message
}
Write-Output ""
# If the URL is empty, throw error
if ($url -eq "") {
throw "URL is empty"
}
# Specific logic for VCLibs alternate method
if ($Name -eq "VCLibs") {
if ($DebugMode) {
Write-Output "URL: $($url)`n"
}
Write-Output "Installing ${arch} ${Name}..."
Add-AppxPackage $url -ErrorAction Stop
Write-Output "`n$Name installed successfully."
}
# Specific logic for UI.Xaml
if ($Name -eq "UI.Xaml") {
$TempFolder = Get-TempFolder
$uiXaml = @{
url = $url
appxFolder = "tools/AppX/$arch/Release/"
appxFilename = "Microsoft.UI.Xaml.$AppxFileVersion.appx"
nupkgFilename = Join-Path -Path $TempFolder -ChildPath "Microsoft.UI.Xaml.$NupkgVersion.nupkg"
nupkgFolder = Join-Path -Path $TempFolder -ChildPath "Microsoft.UI.Xaml.$NupkgVersion"
}
# Debug
if ($DebugMode) {
$formattedDebugOutput = ($uiXaml | ConvertTo-Json -Depth 10 -Compress) -replace '\\\\', '\'
Write-Output "uiXaml:"
Write-Output $formattedDebugOutput
Write-Output ""
}
# Downloading
Write-Output "Downloading UI.Xaml..."
if ($DebugMode) {
Write-Output "URL: $($uiXaml.url)"
}
Invoke-WebRequest -Uri $uiXaml.url -OutFile $uiXaml.nupkgFilename
# Check if folder exists and delete if needed (will occur whether DisableCleanup is $true or $false)
Cleanup -Path $uiXaml.nupkgFolder -Recurse
# Extracting
Write-Output "Extracting...`n"
if ($DebugMode) {
Write-Output "Into folder: $($uiXaml.nupkgFolder)`n"
}
Add-Type -Assembly System.IO.Compression.FileSystem
[IO.Compression.ZipFile]::ExtractToDirectory($uiXaml.nupkgFilename, $uiXaml.nupkgFolder)
# Prep for install
Write-Output "Installing ${arch} ${Name}..."
$XamlAppxFolder = Join-Path -Path $uiXaml.nupkgFolder -ChildPath $uiXaml.appxFolder
$XamlAppxPath = Join-Path -Path $XamlAppxFolder -ChildPath $uiXaml.appxFilename
# Debugging
if ($DebugMode) { Write-Output "Installing appx Packages in: $XamlAppxFolder" }
# Install
Get-ChildItem -Path $XamlAppxPath -Filter *.appx | ForEach-Object {
if ($DebugMode) { Write-Output "Installing appx Package: $($_.Name)" }
Add-AppxPackage $_.FullName -ErrorAction Stop
}
Write-Output "`nUI.Xaml installed successfully."
# Cleanup
if ($DisableCleanup -eq $false) {
if ($DebugMode) { Write-Output "" } # Extra line break for readability if DebugMode is enabled
Cleanup -Path $uiXaml.nupkgFilename
Cleanup -Path $uiXaml.nupkgFolder -Recurse $true
}
}
} catch {
# If unable to connect to remote server and Windows 10 or Server 2022, display warning message
$ShowOldVersionMessage = $False
if ($_.Exception.Message -match "Unable to connect to the remote server") {
# Determine the correct Windows caption and set $ShowOutput to $True if conditions are met
if ($osVersion.Type -eq "Workstation" -and $osVersion.NumericVersion -eq 10) {
$WindowsCaption = "Windows 10"
$ShowOldVersionMessage = $True
} elseif ($osVersion.Type -eq "Server" -and $osVersion.NumericVersion -eq 2022) {
$WindowsCaption = "Server 2022"
$ShowOldVersionMessage = $True
}
# Output the warning message if $ShowOldVersionMessage is $True, otherwise output the generic error message
if ($ShowOldVersionMessage) {
$OldVersionMessage = "There is an issue connecting to the server to download $Name. Unfortunately this is a known issue with the prerequisite server URLs - sometimes they are down. Since you're using $WindowsCaption you must use the non-store versions of the prerequisites, the prerequisites from the Windows store will not work, so you may need to try again later or install manually."
Write-Warning $OldVersionMessage
} else {
Write-Warning "Error when trying to download or install $Name. Please try again later or manually install $Name."
}
}
$errorHandled = Handle-Error $_
if ($null -ne $errorHandled) {
throw $errorHandled
}
$errorHandled = $null
}
}
}
# ============================================================================ #
# Initial checks
# ============================================================================ #
# Check for updates if -CheckForUpdate is specified
if ($CheckForUpdate) {
CheckForUpdate -RepoOwner $RepoOwner -RepoName $RepoName -CurrentVersion $CurrentVersion -PowerShellGalleryName $PowerShellGalleryName
}
# Heading
Write-Output "winget-install $CurrentVersion"
Write-Output "To check for updates, run winget-install -CheckForUpdate"
# Set OS version
$osVersion = Get-OSInfo
# Set architecture type
$arch = $osVersion.Architecture
# If it's a workstation, make sure it is Windows 10+
if ($osVersion.Type -eq "Workstation" -and $osVersion.NumericVersion -lt 10) {
Write-Error "winget is only compatible with Windows 10 or greater."
exit 1
}
# If it's a workstation with Windows 10, make sure it's version 1809 or greater
if ($osVersion.Type -eq "Workstation" -and $osVersion.NumericVersion -eq 10 -and $osVersion.ReleaseId -lt 1809) {
Write-Error "winget is only compatible with Windows 10 version 1809 or greater."
exit 1
}
# If it's a server, it needs to be 2022+
if ($osVersion.Type -eq "Server" -and $osVersion.NumericVersion -lt 2022) {
Write-Error "winget is only compatible with Windows Server 2022+."
exit 1
}
# Check if winget is already installed
if (Get-WingetStatus) {
if ($Force -eq $false) {
Write-Output "winget is already installed, exiting..."
exit 0
}
}
# ============================================================================ #
# Beginning of installation process
# ============================================================================ #
try {
# ============================================================================ #
# Install prerequisites
# ============================================================================ #
# VCLibs
Install-Prerequisite -Name "VCLibs" -Version "14.00" -Url "https://store.rg-adguard.net/api/GetFiles" -AlternateUrl "https://aka.ms/Microsoft.VCLibs.$arch.14.00.Desktop.appx" -ContentType "application/x-www-form-urlencoded" -Body "type=PackageFamilyName&url=Microsoft.VCLibs.140.00_8wekyb3d8bbwe&ring=RP&lang=en-US"
# UI.Xaml
Install-Prerequisite -Name "UI.Xaml" -Version "2.7.3" -Url "https://store.rg-adguard.net/api/GetFiles" -AlternateUrl "https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.3" -ContentType "application/x-www-form-urlencoded" -Body "type=ProductId&url=9P5VK8KZB5QZ&ring=RP&lang=en-US" -NupkgVersion "2.7.3" -AppxFileVersion "2.7"
# ============================================================================ #
# Install winget
# ============================================================================ #
$TempFolder = Get-TempFolder
# Output
Write-Section "Downloading & installing winget..."
Write-Output "Retrieving download URL for winget from GitHub..."
$wingetUrl = Get-WingetDownloadUrl -Match "msixbundle"
$wingetPath = Join-Path -Path $tempFolder -ChildPath "winget.msixbundle"
$wingetLicenseUrl = Get-WingetDownloadUrl -Match "License1.xml"
$wingetLicensePath = Join-Path -Path $tempFolder -ChildPath "license1.xml"
# If the URL is empty, throw error
if ($wingetUrl -eq "") {
throw "URL is empty"
}
Write-Output "Downloading winget..."
if ($DebugMode) {
Write-Output "`nURL: $wingetUrl"
Write-Output "Saving as: $wingetPath"
}
Invoke-WebRequest -Uri $wingetUrl -OutFile $wingetPath
Write-Output "Downloading license..."
if ($DebugMode) {
Write-Output "`nURL: $wingetLicenseUrl"
Write-Output "Saving as: $wingetLicensePath"
}
Invoke-WebRequest -Uri $wingetLicenseUrl -OutFile $wingetLicensePath
Write-Output "`nInstalling winget..."
# Debugging
if ($DebugMode) {
Write-Output "wingetPath: $wingetPath"
Write-Output "wingetLicensePath: $wingetLicensePath"
}
# Try to install winget
try {
# Add-AppxPackage will throw an error if the app is already installed or higher version installed, so we need to catch it and continue
Add-AppxProvisionedPackage -Online -PackagePath $wingetPath -LicensePath $wingetLicensePath -ErrorAction SilentlyContinue | Out-Null
Write-Output "`nwinget installed successfully."
} catch {
$errorHandled = Handle-Error $_
if ($null -ne $errorHandled) {
throw $errorHandled
}
$errorHandled = $null
}
# Cleanup
if ($DisableCleanup -eq $false) {
if ($DebugMode) { Write-Output "" } # Extra line break for readability if DebugMode is enabled
Cleanup -Path $wingetPath
Cleanup -Path $wingetLicensePath
}
# ============================================================================ #
# PATH environment variable
# ============================================================================ #
# Add the WindowsApps directory to the PATH variable
Write-Section "Checking and adding WindowsApps directory to PATH variable for current user if not present..."
$WindowsAppsPath = [IO.Path]::Combine([Environment]::GetEnvironmentVariable("LOCALAPPDATA"), "Microsoft", "WindowsApps")
Update-PathEnvironmentVariable -NewPath $WindowsAppsPath
# ============================================================================ #
# Finished
# ============================================================================ #
Write-Section "Installation complete!"
# Timeout for 5 seconds to check winget
Write-Output "Checking if winget is installed and working..."
Start-Sleep -Seconds 3
# Check if winget is installed
if (Get-WingetStatus -eq $true) {
Write-Output "winget is installed and working now, you can go ahead and use it."
} else {
Write-Warning "winget is installed but is not detected as a command. Try using winget now. If it doesn't work, wait about 1 minute and try again (it is sometimes delayed). Also try restarting your computer."
Write-Warning "If you restart your computer and the command still isn't recognized, please read the Troubleshooting section`nof the README: https://github.com/asheroto/winget-install#troubleshooting`n"
Write-Warning "Make sure you have the latest version of the script by running this command: $PowerShellGalleryName -CheckForUpdate"
}
} catch {
# ============================================================================ #
# Error handling
# ============================================================================ #
Write-Section "WARNING! An error occurred during installation!"
Write-Warning "If messages above don't help and the problem persists, please read the Troubleshooting section`nof the README: https://github.com/asheroto/winget-install#troubleshooting"
Write-Warning "Make sure you have the latest version of the script by running this command: $PowerShellGalleryName -CheckForUpdate"
# If it's not 0x80073D02 (resources in use), show error
if ($_.Exception.Message -notmatch '0x80073D02') {
if ($DebugMode) {
Write-Warning "Line number : $($_.InvocationInfo.ScriptLineNumber)"
}
Write-Warning "Error: $($_.Exception.Message)`n"
}
}

View File

@ -996,31 +996,97 @@
</TabItem>
<TabItem Header="Updates" Visibility="Collapsed" Name="WPFTab4">
<ScrollViewer VerticalScrollBarVisibility="Auto" Margin="{DynamicResource TabContentMargin}">
<Grid Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Grid.Row="0" Grid.Column="0" Style="{StaticResource BorderStyle}">
<StackPanel Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True">
<Button Name="WPFUpdatesdefault" FontSize="{DynamicResource ConfigTabButtonFontSize}" Height="Auto" Width="Auto" Content="Default (Out of Box) Settings" Margin="20,4,20,10" Padding="10"/>
<TextBlock Foreground="{DynamicResource ComboBoxForegroundColor}" Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300">This is the default settings that come with Windows. <LineBreak/><LineBreak/> No modifications are made and will remove any custom windows update settings.<LineBreak/><LineBreak/>Note: If you still encounter update errors, reset all updates in the config tab. That will restore ALL Microsoft Update Services from their servers and reinstall them to default settings.</TextBlock>
</StackPanel>
</Border>
<Border Grid.Row="0" Grid.Column="1" Style="{StaticResource BorderStyle}">
<StackPanel Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True">
<Button Name="WPFUpdatessecurity" FontSize="{DynamicResource ConfigTabButtonFontSize}" Height="Auto" Width="Auto" Content="Security (Recommended) Settings" Margin="20,4,20,10" Padding="10"/>
<TextBlock Foreground="{DynamicResource ComboBoxForegroundColor}" Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300">This is my recommended setting I use on all computers.<LineBreak/><LineBreak/> It will delay feature updates by 2 years and will install security updates 4 days after release.<LineBreak/><LineBreak/>Feature Updates: Adds features and often bugs to systems when they are released. You want to delay these as long as possible.<LineBreak/><LineBreak/>Security Updates: Typically these are pressing security flaws that need to be patched quickly. You only want to delay these a couple of days just to see if they are safe and don't break other systems. You don't want to go without these for ANY extended periods of time.</TextBlock>
</StackPanel>
</Border>
<Border Grid.Row="0" Grid.Column="2" Style="{StaticResource BorderStyle}">
<StackPanel Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True">
<Button Name="WPFUpdatesdisable" FontSize="{DynamicResource ConfigTabButtonFontSize}" Height="Auto" Width="Auto" Content="Disable ALL Updates (NOT RECOMMENDED!)" Margin="20,4,20,10" Padding="10,10,10,10"/>
<TextBlock Foreground="{DynamicResource ComboBoxForegroundColor}" Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300">This completely disables ALL Windows Updates and is NOT RECOMMENDED.<LineBreak/><LineBreak/> However, it can be suitable if you use your system for a select purpose and do not actively browse the internet. <LineBreak/><LineBreak/>Note: Your system will be easier to hack and infect without security updates.</TextBlock>
<TextBlock Text=" " Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300"/>
</StackPanel>
</Border>
<Grid Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <!-- Row for the 3 columns -->
<RowDefinition Height="Auto"/> <!-- Row for Windows Version -->
</Grid.RowDefinitions>
<!-- Three columns container -->
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Default Settings -->
<Border Grid.Column="0" Style="{StaticResource BorderStyle}">
<StackPanel>
<Button Name="WPFFixesUpdate"
FontSize="{DynamicResource ConfigTabButtonFontSize}"
Content="Default Settings"
Margin="10,5"
Padding="10"/>
<TextBlock Margin="10"
TextWrapping="Wrap"
Foreground="{DynamicResource MainForegroundColor}">
<Run FontWeight="Bold">Default Windows Update Configuration</Run>
<LineBreak/>
- No modifications to Windows defaults
<LineBreak/>
- Removes any custom update settings
<LineBreak/><LineBreak/>
<Run FontStyle="Italic" FontSize="11">Note: This resets your Windows Update settings to default out of the box settings. It removes ANY policy or customization that has been done to Windows Update.</Run>
</TextBlock>
</StackPanel>
</Border>
<!-- Security Settings -->
<Border Grid.Column="1" Style="{StaticResource BorderStyle}">
<StackPanel>
<Button Name="WPFUpdatessecurity"
FontSize="{DynamicResource ConfigTabButtonFontSize}"
Content="Security Settings"
Margin="10,5"
Padding="10"/>
<TextBlock Margin="10"
TextWrapping="Wrap"
Foreground="{DynamicResource MainForegroundColor}">
<Run FontWeight="Bold">Balanced Security Configuration</Run>
<LineBreak/>
- Feature updates delayed by 2 years
<LineBreak/>
- Security updates installed after 4 days
<LineBreak/><LineBreak/>
<Run FontWeight="SemiBold">Feature Updates:</Run> New features and potential bugs
<LineBreak/>
<Run FontWeight="SemiBold">Security Updates:</Run> Critical security patches
<LineBreak/><LineBreak/>
<Run FontStyle="Italic" FontSize="11">Note: This only applies to Pro systems that can use group policy.</Run>
</TextBlock>
</StackPanel>
</Border>
<!-- Disable Updates -->
<Border Grid.Column="2" Style="{StaticResource BorderStyle}">
<StackPanel>
<Button Name="WPFUpdatesdisable"
FontSize="{DynamicResource ConfigTabButtonFontSize}"
Content="Disable All Updates"
Foreground="Red"
Margin="10,5"
Padding="10"/>
<TextBlock Margin="10"
TextWrapping="Wrap"
Foreground="{DynamicResource MainForegroundColor}">
<Run FontWeight="Bold" Foreground="Red">!! Not Recommended !!</Run>
<LineBreak/>
- Disables ALL Windows Updates
<LineBreak/>
- Increases security risks
<LineBreak/>
- Only use for isolated systems
<LineBreak/><LineBreak/>
<Run FontStyle="Italic" FontSize="11">Warning: Your system will be vulnerable without security updates.</Run>
</TextBlock>
</StackPanel>
</Border>
</Grid>
<!-- Future Implementation: Add Windows Version to updates panel -->
<Grid Name="updatespanel" Grid.Row="1" Background="Transparent">
</Grid>
</Grid>
</ScrollViewer>
</TabItem>