Hi, noob here.
I've put a script called admin.ahk in my startup folder.
Why am I getting this error on startup?
p.s. I just found this somewhere, I don't fully undestand it, but I do want the script to run elevated.
Thanks!
run script as admin on startup error window
Re: run script as admin on startup error window
It could be because the operation was canceled by the user?
Posting your script may be the next step to help track down the problem.
Posting your script may be the next step to help track down the problem.
Re: run script as admin on startup error window
@mikeyww
The whole thing is pretty long, but the first few lines look like this:
After that it's just a bunch of regular old hotkeys.
The whole thing is pretty long, but the first few lines look like this:
Code: Select all
SetWorkingDir A_ScriptDir ; Ensures a consistent starting directory.
SetTitleMatchMode 2 ; match any part of the title
CoordMode("Mouse","Screen")
#SingleInstance Force
#NoTrayIcon
if A_IsAdmin="0" {
Run("*RunAs " A_ScriptFullPath)
ExitApp
}
Re: run script as admin on startup error window
If the script's path is the one in the msgbox window, could you try wrapping a_scriptfullpath in double quotes?
exploded for clarity: Run("*RunAs " . '"' . A_ScriptFullPath . '"')
exploded for clarity: Run("*RunAs " . '"' . A_ScriptFullPath . '"')
Re: run script as admin on startup error window
@coffee Thanks, I'll try that and let you know on the next reboot.
Re: run script as admin on startup error window
Did it work?
If not try below without exitapp? Is exitapp necessary if the #singleinstance force directive is in place?
If not try below without exitapp? Is exitapp necessary if the #singleinstance force directive is in place?
Code: Select all
if !A_IsAdmin
Run '*RunAs "' A_ScriptFullPath '"'