Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

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