diff --git a/script.ps1 b/script.ps1 index 62e94dc..523241f 100644 --- a/script.ps1 +++ b/script.ps1 @@ -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