-1

I need to run an AutoIt program with administrator privileges. I use #requireadmin while installing. Is that enough to run the program after install with administrative privileges without using #requireadmin or should I try something else?

user4157124
  • 2,809
  • 13
  • 27
  • 42
Kumar
  • 110
  • 14
  • 1
    What you means under "install"? Can you explain and show some example of code? #requireadmin specifies that the current script requires full administrator rights to run. – matrix Sep 19 '17 at 04:51
  • I use 2 programs - one installs, other starts hotspot. I use #requireadmin in the 1st program to install the 2nd program in the programs folder.. I need administrator privileges to start hotspot. My question is whether I have to use #requireadmin in the 2nd program also or can I run it without using #requireadmin? – Kumar Sep 19 '17 at 07:26
  • You must use #requireadmin in the 2nd program. – matrix Sep 19 '17 at 11:31

2 Answers2

2

You must use #requireadmin in the 2nd program because it is affects current script only.

matrix
  • 513
  • 3
  • 8
  • Is there any other way to run the 2nd program without using #requireadmin? How are the professional softwares are running then? – Kumar Sep 19 '17 at 12:49
  • It depends of software specific. For example You can register your software as service and run it as local system. – matrix Sep 19 '17 at 15:35
1

When you install your program and it is run with admin privileges, you can create a scheduled task that has the "run with highest privileges" option set. Then later when your application is run without admin privileges it can run this task in order to gain admin privileges.

Search around for ObjCreate("Schedule.Service") or for task scheduler UDFs for how to do this. Also for examples and documentation for the task scheduler com object in windows here.

garbb
  • 679
  • 5
  • 9