Running cmd.exe as admin

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
WantToKnow
Posts: 65
Joined: 28 Mar 2020, 08:46

Running cmd.exe as admin

Post by WantToKnow » 27 May 2024, 05:41

To change the date I need to run my batch file as an admin.
This works:

Code: Select all

    SetDate := A_DD "." A_MM "." 2014
    FileAppend % "Date " SetDate, % A_ScriptDir "\" "TmpDate.bat"
    RunWait *RunAs "%A_ScriptDir%\TmpDate.bat"

Now I want to do the same without creating a batch file before just using cmd.exe

Code: Select all

    cmdPath := A_ScriptDir "\cmd.exe"
    if FileExist(cmdPath)
    RunWait *RunAs "%A_ScriptDir%\cmd.exe date 10.05.2014"

Unfortunately this doesn't work.
A big thanks for your help!

User avatar
mikeyww
Posts: 27373
Joined: 09 Sep 2014, 18:38

Re: Running cmd.exe as admin

Post by mikeyww » 27 May 2024, 07:54

Hello,

Since Windows can automatically synchronize its date with servers using time standards, I suppose that in most cases where people are attempting to change their computer's date, they are attempting to circumvent other software with timed expirations. I don't think that this forum supports that type of activity.

Code: Select all

#Requires AutoHotkey v1.1.33.11
RunWait % "*RunAs " A_ComSpec " /c DATE 05/20/2024",, Hide
MsgBox 64, Status, Done!
You need not look far for this type of example; it's in the documentation under Run.

https://www.autohotkey.com/docs/v1/lib/Run.htm#Remarks

Post Reply

Return to “Ask for Help (v1)”