Sign in to follow this  
Followers 0
gcue

uptime on remote pc?

5 posts in this topic

has anyone figured out how to do this?

thx

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

id like to be able to do it through autoit - if possible. (ive already this whole arsenal of tools built into one tool - would like to keep it within autoit :)

Edited by gcue

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Yes, it can be done. You need to look into WMI objects. You can query remote systems directly and return all sorts of info.

Here is an example. (none of this code will work standalone, I just want to point you in the right direction.)

Func get_compsystem()
    $objWMIService = ObjGet("winmgmts:\\" & $comp_name & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    For $objItem In $colItems
        $bios_brand = $objItem.Manufacturer
        $bios_model = $objItem.Model
        $totalmem = Round($objItem.TotalPhysicalMemory / 1024 / 1024,0) & ' MB'
        $logged_on_user = $objItem.UserName; logged on user. if no user this will be blank.
    Next
EndFunc

For uptime however look into

colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

Your interested in

$lbt = $objItem.LastBootUpTime

$ldt = $objItem.LocalDateTime

to get the last boot and local time of the remote system. Use

_DateDiff

to get the difference in seconds and then calculate it out to get your answer in days,hours,min,seconds.

Look for a script called "scriptomatic". Its an amazing piece of work that shows examples of how to use WMI in autoit while showing the results from querying your own machine.

Hopefully this points you in the right direction. When I discovered WMI objects I suddenly had a means to get amost any info I needed from network machines. Check them out. Scriptomatic helped me alot in figuring out how to interact with them.

Edited by cal

Share this post


Link to post
Share on other sites

I had to do this in a project I did.

With some help from ChrisL at work, I used this.

#include <Date.au3>

$aTSB = DllCall ("kernel32.dll", "long", "GetTickCount")
$ticksSinceBoot = $aTSB[0]


dim $iHours, $iMins, $iSecs
_TicksToTime ( $ticksSinceBoot, $iHours, $iMins, $iSecs )

$iDays = int($iHours / 24)
$iHours = $iHours - ($iDays * 24)

$uptime = ($iDays& " days, "&$iHours &" hours, "&$iMins & " Minutes, and "&$iSecs& " Seconds" )


msgbox(0,"Computer Uptime",$uptime)

Hope it helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0