10 kb of Powerbasic ... you're cheating, it's pascal here ;-)
You can do this with just 1kb of PowerShell ...
( may be Pascal script could even be shorter ...)
File uptime.ps1 :
$MethodDefinition = @"
[DllImport("kernel32")] public extern static UInt64 GetTickCount64();
"@
$Kernel32 = Add-Type -MemberDefinition $MethodDefinition -Name
'Kernel32' -Namespace 'Win32' -PassThru
#milliseconds
$tc= $Kernel32::GetTickCount64()
# seconds
$t= ($tc-$tc % 1000)/1000
$s= $t%60
# minutes
$tm=($t-$s)/60
$m= $tm % 60
#hours
$th=($tm-$m)/60
$h=$th % 24
#days
$d=($th-$h)/24
$Result="{0:d2}:{1:d2}:{2:d2}" -f $h,$m,$s
if ($d -ne 0)
{
$Result= "{0} {1}" -f $d,$Result
}
Write-Host $Result
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal