ainner Posted January 30, 2006 Posted January 30, 2006 (edited) I want to perform an action if a computer has been up for more than 3 days. Right now the only way I found of doing it is by using a VbScript...Since I don't wanna overcomplicated things I would be happy if someone would have a solution not requiring VbScript or at least least using it as simple as possible...Thx Edited January 30, 2006 by ainner
ChrisL Posted January 30, 2006 Posted January 30, 2006 I want to perform an action if a computer has been up for more than 3 days. Right now the only way I found of doing it is by using a VbScript...Since I don't wanna overcomplicated things I would be happy if someone would have a solution not requiring VbScript or at least least using it as simple as possible...ThxThere is timerinit() functions and time and date functions see the help file, you could get the current date and time and work out which date and time you need to do what from that, periodically check the current date and time and if it matches then perform your action, or timerinit() but I don't know if using the timerinit() is acceptable over a 3 day period or not. [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
CyberSlug Posted January 30, 2006 Posted January 30, 2006 http://www.autoitscript.com/forum/index.ph...topic=18257&hl=Might need AutoIt beta version Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
GaryFrost Posted January 30, 2006 Posted January 30, 2006 needs beta expandcollapse popup#include <Date.au3> $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output = "" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $LastBootUp = WMIDateStringToDate($objItem.LastBootUpTime) $LocalDateTime = WMIDateStringToDate($objItem.LocalDateTime) $Output = $Output & "In Years: " & _DateDiff("Y", $LastBootUp, $LocalDateTime) & @CRLF $Output = $Output & "In Months: " & _DateDiff("M", $LastBootUp, $LocalDateTime) & @CRLF $Output = $Output & "In Weeks: " & _DateDiff("W", $LastBootUp, $LocalDateTime) & @CRLF $Output = $Output & "In Days: " & _DateDiff("D", $LastBootUp, $LocalDateTime) & @CRLF $Output = $Output & "In Hours: " & _DateDiff("h", $LastBootUp, $LocalDateTime) & @CRLF $Output = $Output & "In Minutes: " & _DateDiff("n", $LastBootUp, $LocalDateTime) & @CRLF $Output = $Output & "In Seconds: " & _DateDiff("s", $LastBootUp, $LocalDateTime) & @CRLF $Output = $Output & "LastBootUpTime: " & $LastBootUp & @CRLF $Output = $Output & "LocalDateTime: " & $LocalDateTime & @CRLF If MsgBox(1, "WMI Output", $Output) = 2 Then ExitLoop $Output = "" Next Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_OperatingSystem") EndIf Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 1, 4) & "/" & _ StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & _ " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate, 13, 2)) EndFunc ;==>WMIDateStringToDate SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
ainner Posted January 30, 2006 Author Posted January 30, 2006 Thx a lot it's working like a charm... gafrost : The code you provided is vbscript right ? You are able to run thsi under autoit with the beta ???
GaryFrost Posted January 30, 2006 Posted January 30, 2006 Thx a lot it's working like a charm...gafrost : The code you provided is vbscript right ? You are able to run thsi under autoit with the beta ??? Nope, it is AutoIt, just use WMI thru ObjectsLook for Scriptomatic in the Scripts and Scraps portion of the forum, you'll find that a handy tool.Gary SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
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