What's the best way to run my AHK script as ADMIN at startup (Win 10 64-bit PC)? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Timmy347
Posts: 109
Joined: 26 Aug 2017, 12:15

What's the best way to run my AHK script as ADMIN at startup (Win 10 64-bit PC)?

27 Sep 2021, 19:32

The script I want to start when my Win10 pc starts is just one line:

RAlt::Send !{f4}

But this line must run as ADMIN else it won't function right.

Lots of different ways to do this online. But some look very dated.

Easiest way for 2021?

thanks!
Timmy347
Posts: 109
Joined: 26 Aug 2017, 12:15

Re: What's the best way to run my AHK script as ADMIN at startup (Win 10 64-bit PC)?

28 Sep 2021, 21:07

mikeyww wrote:
27 Sep 2021, 19:42
I'm not sure about previous years, but this year, you could do it this way: https://www.autohotkey.com/docs/commands/Run.htm#RunAs
Thanks!

That works good.

The only problem is that MS Windows presents me with that big yellow screen at PC startup, asking me if i'm SURE that I want to start my script.

Way around this?
TAC109
Posts: 1111
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: What's the best way to run my AHK script as ADMIN at startup (Win 10 64-bit PC)?

28 Sep 2021, 23:45

You may be able to make use of RunAsTask.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
RussF
Posts: 1264
Joined: 05 Aug 2021, 06:36

Re: What's the best way to run my AHK script as ADMIN at startup (Win 10 64-bit PC)?

29 Sep 2021, 07:59

You could just create a task in the Windows Task Scheduler to run at startup or login. It's a lot easier than creating a script to do it for you.
When you create it from the Action menu, choose "Create Task", not "Create basic task". That will give you the option to select "Run with highest privileges." There are lots of tutorials or youtube videos to show you how to create a task.

Russ
Timmy347
Posts: 109
Joined: 26 Aug 2017, 12:15

Re: What's the best way to run my AHK script as ADMIN at startup (Win 10 64-bit PC)?

30 Sep 2021, 03:45

RussF wrote:
29 Sep 2021, 07:59
You could just create a task in the Windows Task Scheduler to run at startup or login. It's a lot easier than creating a script to do it for you.
When you create it from the Action menu, choose "Create Task", not "Create basic task". That will give you the option to select "Run with highest privileges." There are lots of tutorials or youtube videos to show you how to create a task.
Thanks, that's a good idea.

It seems that, in Task Scheduler, I can't just link to the AHK file.

Instead, I have to link to the exe itself, and pass the exe arguments to run my specific file.

Do you know what they are? It seems there should be some sort of OPEN command that i can use to pass my ahk file to. Something like this:

AutoHotkey.exe -open "c:\my cool scripts\my startup script.ahk"

<see image>

https://i.imgur.com/KidOlbC.jpg

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 233 guests