How to replicate the system boot time command Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
AHKStudent
Posts: 1055
Joined: 05 May 2018, 12:23

How to replicate the system boot time command

21 Aug 2020, 05:33

Is there a way to replicate the results of this:

C:\windows\system32>systeminfo | find "System Boot Time"
System Boot Time: 8/18/2020, 6:39:24 AM

I looked at the built in variable list but didnt find anything.
RubbeH
Posts: 44
Joined: 13 Jul 2020, 08:40

Re: How to replicate the system boot time command

21 Aug 2020, 06:33

I don't really understand what you mean?
But you can do something like this.

Code: Select all

DetectHiddenWindows, On
F2::
{
ClipSave := ClipboardAll
Run, cmd.exe,,hide,myCMD
WinWait, ahk_pid %myCMD%
ControlSend,, systeminfo | find "System Boot Time" | clip {enter}
sleep 1000
MsgBox %clipboard%
Clipboard := ClipSave
}
return
User avatar
boiler
Posts: 6838
Joined: 21 Dec 2014, 02:44

Re: How to replicate the system boot time command

21 Aug 2020, 06:44

You can use A_TickCount, which is the number of milliseconds that have elapsed since the system was started, and the current time to calculate the system start time.
lexikos
Posts: 7173
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: How to replicate the system boot time command  Topic is solved

21 Aug 2020, 08:02

In addition to what boiler said, since it might not be obvious, you can use EnvAdd with a negative value to subtract time from the current date, and FormatTime to convert it to a more readable form.
RickC
Posts: 253
Joined: 27 Oct 2013, 08:32

Re: How to replicate the system boot time command

24 Aug 2020, 15:39

AHKStudent wrote:
21 Aug 2020, 05:33
Is there a way to replicate the results of this:

C:\windows\system32>systeminfo | find "System Boot Time"
Another way to get System Boot Time... PowerShell wrapped in AHK:

Code: Select all

psScript =
(
    (gcim Win32_OperatingSystem).LastBootUpTime | Clip
)

RunWait PowerShell.exe -Command %psScript%,, hide
MsgBox, %Clipboard%
Or System Uptime:

Code: Select all

psScript =
(
    (get-date) - (gcim Win32_OperatingSystem).LastBootUpTime | Clip
)

RunWait PowerShell.exe -Command %psScript%,, hide
MsgBox, %Clipboard%

Hope this helps...

Return to “Ask For Help”

Who is online

Users browsing this forum: djuga, Google [Bot], Jayinem, manehscripts and 27 guests