exitcodes added
This commit is contained in:
parent
ada7de982c
commit
b296bf80ad
|
@ -84,11 +84,15 @@ function Execpause {
|
|||
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
|
||||
}
|
||||
function Execquite {
|
||||
param (
|
||||
[Parameter(Mandatory=$false,Position=0)][System.Int32]$exitcode=0
|
||||
)
|
||||
if ($show -ne "qn") {
|
||||
Execpause
|
||||
}
|
||||
$logger.Add("execution time is $((Get-Date).Second-$tStart) seconds, exit")
|
||||
Set-Location -Path $dStart
|
||||
$host.SetShouldExit($exitcode)
|
||||
Exit
|
||||
}
|
||||
function Execerror {
|
||||
|
@ -96,7 +100,7 @@ function Execerror {
|
|||
[Parameter(Mandatory=$false,Position=0)][System.String]$message=""
|
||||
)
|
||||
$logger.Add("error: $message")
|
||||
Execquite
|
||||
Execquite(1)
|
||||
}
|
||||
|
||||
|
||||
|
@ -113,8 +117,8 @@ $logger = New-Object Logger -ArgumentList $config."logs"
|
|||
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
|
||||
if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||
Write-Host "Running as $env:USERNAME"
|
||||
Execquite(0)
|
||||
}
|
||||
else {
|
||||
Execerror("Restart this as Administrator!")
|
||||
}
|
||||
Execquite
|
||||
|
|
Loading…
Reference in New Issue
Block a user