troubleshooting Question

Autohotkey script doesn't work on machines that have been up for a long time.

Avatar of MstrBacon
MstrBacon asked on
Scripting LanguagesAutoHotkey
2 Comments1 Solution430 ViewsLast Modified:
This works great on the machine I have autohotkey installed, but not on my test machine, which doesn't. I don't think that matters, because it is compiled as an exe, right? (i know, dumb question)

My test machine has been up for 51 days. However, it only shows it have been up for one day, seven hours, 47 minutes and change.
I inserted the message box because I thought I was crazy, because when I set the max uptime to 14 days, it ran and did nothing on the machine that had been up for 51 days.

If someone (my hero Joe W.?) could please take a look at this and tell me what I am doing wrong, I would really appreciate it.

The files attached are the ahk and a screen shot showing the message box and the system uptime, so you don't think I am nuts.

Here is the code if you don't want to open the file...

#Warn,UseUnsetLocal ; warning on uninitialized variables
#NoTrayIcon ; do not show an icon in the system tray
#NoEnv ; avoid checking empty variables to see if they are environment variables
#SingleInstance ignore ; leave old instance running
SetBatchLines,-1 ; run at maximum speed

T = 20000101000000
T += A_TickCount/1000,Seconds
FormatTime FormdT, %T%, HH:mm:ss
FormatTime Days, %T%, YDay
MsgBox % Days-1 " days " FormdT

; begin params you may want to change
UptimeDaysLimit:=14
NagTimeMinutes:=15
; end params you may want to change

NagTime:=1000*60*NagTimeMinutes ; param to Sleep is in milliseconds
TryAgain:
UptimeSeconds:=A_TickCount/1000
UptimeDays:=UptimeSeconds/(60*60*24)
If (UptimeDays>UptimeDaysLimit)
{
  MsgBox,4401,This Vidant Health Computer Needs a Break!, This system has been up for %UptimeDays% days`n`nClose your open programs, then click OK to reboot`n-----or -----`nHit cancel, or Enter to be reminded again in %NagTimeMinutes% minutes.`n`n`nThanks, Vidant Health Information Services
  IfMsgBox,OK
    Shutdown,2
  Else
  {
    Sleep,%NagTime%
    Goto,TryAgain
  }
}
ExitApp
Untitled.png
RebootNag.ahk
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros