GoogleDude Posted November 10, 2008 Posted November 10, 2008 How can I get the Time and or Date of a computer on my network and set the value as a $var? I tried to use "$Time = RunWait("net time \\192.168.1.123") but it just returns a 0 stating that the command completed. Thanks, GD
rasim Posted November 10, 2008 Posted November 10, 2008 GoogleDude$strComputer = "." ;remote computer name $strResult = "" $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_LocalTime") For $objItem In $colItems $strResult = "Year: " & $objItem.Year & @LF & _ "Quarter: " & $objItem.Quarter & @LF & _ "Month: " & $objItem.Month & @LF & _ "WeekInMonth: " & $objItem.WeekInMonth & @LF & _ "DayOfWeek: " & $objItem.DayOfWeek & @LF & _ "Day: " & $objItem.Day & @LF & _ "Hour: " & $objItem.Hour & @LF & _ "Minute: " & $objItem.Minute & @LF & _ "Second: " & $objItem.Second Next MsgBox(0, "", $strResult)MSDN
GoogleDude Posted November 10, 2008 Author Posted November 10, 2008 Thanks, Now I just have to figure out how to reformat $strResult so that it is in a format that can be set inside a StatusBar of my GUI.
BrettF Posted November 10, 2008 Posted November 10, 2008 Easy, just change the the str result string! $strComputer = ".";remote computer name $strResult = "" $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_LocalTime") For $objItem In $colItems $strResult = $objItem.Month & "/" & _ $objItem.Day & "/" & _ $objItem.Year & " " & _ $objItem.Hour & ":" & _ $objItem.Minute & ":" & _ $objItem.Second & "(MM/DD/YYYY HH:MM:SS)" Next MsgBox(0, "", $strResult) Hope it helps! Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
GoogleDude Posted November 11, 2008 Author Posted November 11, 2008 Easy, just change the the str result string! $strComputer = ".";remote computer name $strResult = "" $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_LocalTime") For $objItem In $colItems $strResult = $objItem.Month & "/" & _ $objItem.Day & "/" & _ $objItem.Year & " " & _ $objItem.Hour & ":" & _ $objItem.Minute & ":" & _ $objItem.Second & "(MM/DD/YYYY HH:MM:SS)" Next MsgBox(0, "", $strResult) Hope it helps! Cheers, Brett It does. Thanks. I think I can achieve my goal with your above sample. Thanks, GD
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now