mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-15 17:30:37 -06:00
fix splitting up in wpfrunspace & catch errors
This commit is contained in:
parent
cb6898d835
commit
a4d1d0fd67
@ -59,8 +59,8 @@ function Invoke-WinUtilTweaks {
|
|||||||
Write-Debug "Service $($service.Name) was changed in the past to $($service.StartType.ToString()) from it's original type of $($psitem.$($values.OriginalService)), will not change it to $($psitem.$($values.service))"
|
Write-Debug "Service $($service.Name) was changed in the past to $($service.StartType.ToString()) from it's original type of $($psitem.$($values.OriginalService)), will not change it to $($psitem.$($values.service))"
|
||||||
$changeservice = $false
|
$changeservice = $false
|
||||||
}
|
}
|
||||||
} catch [System.ServiceProcess.ServiceNotFoundException] {
|
} catch {
|
||||||
Write-Warning "Service $($psitem.Name) was not found"
|
# do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,11 +26,7 @@ Function Set-WinUtilService {
|
|||||||
|
|
||||||
# Service exists, proceed with changing properties
|
# Service exists, proceed with changing properties
|
||||||
$service | Set-Service -StartupType $StartupType -ErrorAction Stop
|
$service | Set-Service -StartupType $StartupType -ErrorAction Stop
|
||||||
} catch [System.ServiceProcess.ServiceNotFoundException] {
|
|
||||||
Write-Warning "Service $Name was not found"
|
|
||||||
} catch {
|
} catch {
|
||||||
Write-Warning "Unable to set $Name due to unhandled exception"
|
# do nothing
|
||||||
Write-Warning $_.Exception.Message
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,14 @@ function Invoke-WPFRunspace {
|
|||||||
Param (
|
Param (
|
||||||
$ScriptBlock,
|
$ScriptBlock,
|
||||||
$ArgumentList,
|
$ArgumentList,
|
||||||
$DebugPreference,
|
$DebugPreference
|
||||||
$automation
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($automation = $true) {
|
if ($PARAM_RUN) {
|
||||||
|
write-host "Running in Main Thread"
|
||||||
& $ScriptBlock @ArgumentList @DebugPreference
|
& $ScriptBlock @ArgumentList @DebugPreference
|
||||||
} else {
|
} else {
|
||||||
|
write-host "Running in Runspace"
|
||||||
# Create a PowerShell instance
|
# Create a PowerShell instance
|
||||||
$script:powershell = [powershell]::Create()
|
$script:powershell = [powershell]::Create()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user