if you can't use the udf for whatever reason, check this out. i use uptime in a kixform, so the return value is dumped into a listview. but you should be able to pick at it or at least get an idea of how to pipe it. pipe() function is Shawn's.
Code:
function GetUpTime($comp)
dim $arrName, $shell, $ret[7,1]
$arrName = "Current system uptime","System Availability","Total Uptime",
"Total Downtime", "Total Reboots","Mean Time Between Reboots",
"Total Bluescreens", "Since"
$shell = 'uptime /s ' + $comp + ' | find '
for $j = 0 to ubound($arrName)
$cur = pipe($shell + '"' + $arrName[$j] + '"')
if ubound($cur) >= 0
$pos = instr($cur[0],":")
$ret[$j,0] = trim(substr($cur[0],1, $pos-1))
$ret[$j,1] = trim(substr($cur[0], $pos+1))
else
$ret[$j,0] = $arrName[$j]
endif
next
$GetUpTime = $ret
endfunction
;------------------------------------------------------------------------------------------------------------
function pipe($command)
dim $i,$error,$line
dim $array[255]
dim $redim $redim = ubound($array)
dim $tempfile $tempfile = "%temp%\pipe.tmp"
if exist("$tempfile")
del("$tempfile")
endif
if @inwin = 2 ; win9x
shell '%comspec% /c $command >"$tempfile"'
else ; winnt
shell '%comspec% /c $command >"$tempfile" 2>nul'
endif
$error=@error
if open(10,"$tempfile") = 0
$i=0
$line = readline(10)
while not @error
if $line
$array[$i] = $line
if $i = $redim
$redim=$redim*2
redim preserve $array[$redim]
endif
$i=$i+1
endif
$line = readline(10)
loop
$=close(10)
del "$tempfile"
if $i > 0
redim preserve $array[$i-1]
$pipe=$array
else
$pipe = 0
endif
exit $error
else
$pipe = 0
exit @error
endif
endfunction
Here's one way you could use it as is.
Code:
$UPTIME = GetUpTime($ComputerName)
for $j = 0 to ubound($UPTIME)
? $UPTIME[$j,0] " : " $UPTIME[$j,1]
next