mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-16 01:40:35 -06:00
a86b07a826
https://learn.microsoft.com/en-us/dotnet/api/system.windows.shell.taskbariteminfo?view=windowsdesktop-8.0
62 lines
2.3 KiB
PowerShell
62 lines
2.3 KiB
PowerShell
function Invoke-WinUtilFeatureInstall {
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
Converts all the values from the tweaks.json and routes them to the appropriate function
|
|
|
|
#>
|
|
|
|
param(
|
|
$CheckBox
|
|
)
|
|
|
|
$sync["Form"].taskbarItemInfo.ProgressState = "Normal"
|
|
$sync["Form"].taskbarItemInfo.ProgressValue = 1 # Get amount of affected features & scripts
|
|
|
|
$CheckBox | ForEach-Object {
|
|
if($sync.configs.feature.$psitem.feature){
|
|
Foreach( $feature in $sync.configs.feature.$psitem.feature ){
|
|
Try{
|
|
Write-Host "Installing $feature"
|
|
Enable-WindowsOptionalFeature -Online -FeatureName $feature -All -NoRestart
|
|
}
|
|
Catch{
|
|
if ($psitem.Exception.Message -like "*requires elevation*"){
|
|
Write-Warning "Unable to Install $feature due to permissions. Are you running as admin?"
|
|
}
|
|
|
|
else{
|
|
$sync["Form"].taskbarItemInfo.ProgressState = "Error"
|
|
Write-Warning "Unable to Install $feature due to unhandled exception"
|
|
Write-Warning $psitem.Exception.StackTrace
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if($sync.configs.feature.$psitem.InvokeScript){
|
|
Foreach( $script in $sync.configs.feature.$psitem.InvokeScript ){
|
|
Try{
|
|
$Scriptblock = [scriptblock]::Create($script)
|
|
|
|
Write-Host "Running Script for $psitem"
|
|
Invoke-Command $scriptblock -ErrorAction stop
|
|
}
|
|
Catch{
|
|
if ($psitem.Exception.Message -like "*requires elevation*"){
|
|
Write-Warning "Unable to Install $feature due to permissions. Are you running as admin?"
|
|
}
|
|
|
|
else{
|
|
$sync["Form"].taskbarItemInfo.ProgressState = "Error"
|
|
Write-Warning "Unable to Install $feature due to unhandled exception"
|
|
Write-Warning $psitem.Exception.StackTrace
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ($sync["Form"].taskbarItemInfo.ProgressState -ne "Error"){
|
|
$sync["Form"].taskbarItemInfo.ProgressState = "None"
|
|
}
|
|
}
|