Rework DisableService() : write UserFlagService reg key even although service could not be disable
This commit is contained in:
parent
745049551a
commit
c107756bd5
1 changed files with 8 additions and 6 deletions
14
cleanW10.ps1
14
cleanW10.ps1
|
@ -457,7 +457,14 @@ function DisableService {
|
|||
}
|
||||
Stop-Service -InputObject $service -PassThru | Set-Service -StartupType disabled
|
||||
Write-Host -ForegroundColor Green "done"
|
||||
if ( $params.userService ) {
|
||||
}
|
||||
catch {
|
||||
Write-Host -NoNewLine -ForegroundColor Red "`tError`n`t"
|
||||
write-Host -ForegroundColor DarkRed $Error[0].Exception.Message
|
||||
}
|
||||
finally {
|
||||
Write-host "Value : $($params.userService.getType())"
|
||||
if ( $params.ContainsKey('userService') -and $params.userService -eq $true ) {
|
||||
# For this kind of service, we need to add a key t create a user service
|
||||
# Where user log-in.
|
||||
AddRegKey @{
|
||||
|
@ -467,11 +474,6 @@ function DisableService {
|
|||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host -NoNewLine -ForegroundColor Red "`tError`n`t"
|
||||
write-Host -ForegroundColor DarkRed $Error[0].Exception.Message
|
||||
return
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Host -ForegroundColor Red "`tError : No name or file for action $($MyInvocation.MyCommand.Name)"
|
||||
|
|
Reference in a new issue