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