Set and get the windows system time


How can I set and get the windows system time from an electron application?
Is it possible?


I don’t believe there’s anything in Node to do that directly, but you could probably do it in a C or C# binary and have your application call the binary.


A simple bat file can solve this problem:
time 12:00:00

But how can I run this bat file with administrative privileges?


Super User has answers.


Based on this answer

test.bat file:

@echo off
:: BatchGotAdmin
REM  --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    goto UACPrompt
) else ( goto gotAdmin )

    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params = %*:"=""
    echo UAC.ShellExecute "cmd.exe", "/c %~s0 %*", "", "runas", 1 >> "%temp%\getadmin.vbs"

    del "%temp%\getadmin.vbs"
    exit /B

    pushd "%CD%"
    CD /D "%~dp0"

time %*

And electron can execute it:
require("child_process").exec('test.bat 15:00:00').unref();

Thanks the help