Yesterday I updated AutoHotkey (v.1) with two scripts running. I chose to have them restarted automatically after installation, and it appeared to work.
Today I discovered that the scripts were actually restarted with elevated privileges and thus they did not quite work, as they start all applications with elevated privileges too and those applications suffer from that (for instance: you cannot drag files into them from non-elevated programs, they write files to the wrong virtual/non-virtual folders, and of course the security problems from running normal programs elevated all the time). And as I start many of my most used programs via AutoHotkey, suddenly I had been running most of my programs with elevated privileges without knowing it!
I do not remember seeing any warning about this issue from the setup program, but maybe I wasn't paying enough attention.
Could script restarting perhaps be done non-elevated?
I guess it must be possible to have parts of the setup program run non-elevated to handle this situation. For instance by keeping the initial non-elevated thread running to take care of restarting the script, and just have the elevated core install thread running as an elevated sub-thread or something. Other setup programs seems to be able to handle this, reflected in the "Run now" option when you have just installed a new program; the program is run non-elevated even though the core of the setup program ran elevated.
In case this is too difficult or time-consuming to implement in the AutoHotkey installer, could there perhaps at least be a warning that scripts will be restarted with elevated privileges in case you choose to have them automatically restarted (in case there is no such warning now)?
Of course now I personally know about this, so I won't use the automatic script restarting, but I am just thinking that this could happen to others as well.
[Fixed] Scripts are restarted as admin after setup
Re: Scripts are restarted with elevated privileges after set
Please download the current installer and see if it solves your problem.
I have modified the installer script as follows:You can verify whether you have downloaded the new installer (and not an older cached version) by looking for the above lines.
Of course, if it works and you restart a script which was running as admin, it won't be running as admin anymore...
I have modified the installer script as follows:
Code: Select all
; Remove
Run % (script.exe ? """" script.exe """ " : "") . """" script.path """"
; Add
script.exe ? Run_(script.exe, """" script.path """")
: Run_("""" script.path """")
Of course, if it works and you restart a script which was running as admin, it won't be running as admin anymore...
Re: Scripts are restarted with elevated privileges after set
Thanks, Lexikos! You're fast – I can't keep up with your speed!
I tried downloading the v1.1.19.03 installer (http://ahkscript.org/download/1.1/AutoH ... nstall.exe), did a Repair, and it seems like the problem is gone. My scripts restarted in non-elevated mode, just as I wanted them to do. Thank you!
I tried downloading the v1.1.19.03 installer (http://ahkscript.org/download/1.1/AutoH ... nstall.exe), did a Repair, and it seems like the problem is gone. My scripts restarted in non-elevated mode, just as I wanted them to do. Thank you!
I didn't quite understand this – how could I check for those lines in an .exe file? Or is there another installer that I don't know about?lexikos wrote:You can verify whether you have downloaded the new installer (and not an older cached version) by looking for the above lines.
That is true – I guess that is a tradeoff. Personally I don't run any scripts elevated, though, and my guess is it is most common to run scripts non-elevated.lexikos wrote:Of course, if it works and you restart a script which was running as admin, it won't be running as admin anymore...
Re: Scripts are restarted with elevated privileges after set
When you install AutoHotkey using the installer, you'll find Installer.ahk in C:\Program Files\AutoHotkey. It's basically the installer itself.jhertel wrote:I didn't quite understand this – how could I check for those lines in an .exe file? Or is there another installer that I don't know about?
Btw you can mark the topic as solved (for other users).
Re: Scripts are restarted with elevated privileges after set
Wow, cool.Coco wrote:When you install AutoHotkey using the installer, you'll find Installer.ahk in C:\Program Files\AutoHotkey. It's basically the installer itself.
Do I do that by prefixing "[Solved]" to the subject of the first post? If so, there is not enough room for a meaningful subject anymore… 60 characters seem way to little for the subject field… Do you know if that can be increased?Coco wrote:Btw you can mark the topic as solved (for other users).
Re: Scripts are restarted with elevated privileges after set
There is a discussion about the topic title text here.jhertel wrote:Do I do that by prefixing "[Solved]" to the subject of the first post? If so, there is not enough room for a meaningful subject anymore… 60 characters seem way to little for the subject field… Do you know if that can be increased?
Re: Scripts are restarted with elevated privileges after set
If anyone has this problem, that should be solvable by adding the following at the top of the script (as mentioned in the docs under A_IsAdmin):lexikos wrote:Of course, if it works and you restart a script which was running as admin, it won't be running as admin anymore...
Code: Select all
if not A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%" ; Requires v1.0.92.01+
ExitApp
}
Re: Scripts are restarted with elevated privileges after set
Thanks!Coco wrote:There is a discussion about the topic title text here.
Who is online
Users browsing this forum: No registered users and 7 guests