mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-16 01:40:35 -06:00
73973d7101
changed from manually setting the taskbar overlay, progressvalue and progress state to setting them through a function
61 lines
2.1 KiB
PowerShell
61 lines
2.1 KiB
PowerShell
function Invoke-WinUtilFeatureInstall {
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
Converts all the values from the tweaks.json and routes them to the appropriate function
|
|
|
|
#>
|
|
|
|
param(
|
|
$CheckBox
|
|
)
|
|
|
|
Set-WinUtilTaskbaritem -state "Normal" -value 1
|
|
|
|
$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{
|
|
Set-WinUtilTaskbaritem -state "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{
|
|
Set-WinUtilTaskbaritem -state "Error"
|
|
Write-Warning "Unable to Install $feature due to unhandled exception"
|
|
Write-Warning $psitem.Exception.StackTrace
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ($sync["Form"].taskbarItemInfo.ProgressState -ne "Error"){
|
|
Set-WinUtilTaskbaritem -state "None"
|
|
}
|
|
}
|