I have a autoit script that I am using for automation testing. My autoit script is called from a vb.net file. Dialog box of UAC settings will appear and is stopping the execution of test scripts. Currently I am trying process.startinfo.username and password to give specifically username so it may execute the script. Please guide how can I avoid that UAC during my tests execution.
2 Answers
Either change the script so that it doesn't need to be elevated or launch it from something that is already elevated. You'll need to consent once to elevate the "Something" then you should be ok. You can also use scheduled tasks to launch elevated things, and consent once when setting up the tasks, but not again when the task runs.

- 18,808
- 8
- 56
- 85
-
Can you please explain How can I elevate it. – sam Jul 07 '11 at 07:28
-
You could right-click the VB.NET application that launches the script, and choose Run As Administrator. Or if the VB.NET app is launched from within Visual Studio, launch Visual Studio elevated (again right click, Run As Administrator). You can go as far back the chain as you need to. Then everything that launches is elevated. – Kate Gregory Jul 07 '11 at 11:31
THe only way to avoid it is to sign your assembly with a strong key. There are instructions here on How to: Sign an Assembly. You must first purchase a code signing certificate though from a 3rd party. You can also make your own certificate but I am not sure if signing your code with a custom made certificate will make the UAC screen go away. I would try making your own certificate first and signing your assembly and seeing if that fixes the problem. If not, you can purchase a code signing certificate from several places, such as GoDaddy, VeriSign or from Thawte, just to name a few
-
being signed keeps the dialog from complaining about "an unknown publisher" but doesn't prevent the dialog – Kate Gregory Jul 06 '11 at 16:05
-
@Kate - You are right, but once its signed, isn't there a checkbox on the UAC screen that says "Don't show this again" or something to that effect? – Icemanind Jul 06 '11 at 17:02
-
nope. try running regedit or the like - signed by microsoft and you have to consent every time – Kate Gregory Jul 06 '11 at 17:46
-
@Kate - Actually, using Windows 7, running RegEdit comes right up. To be fair though, I am at work and using my work machine on a domain, so maybe something in the domain is set to allow me admin access or something. Either way, I believe you. I wasn't 100% sure. I will vote your answer up. – Icemanind Jul 06 '11 at 18:05
-
@icemanind Windows 7 only shows UAC sometimes - if you've launched a signed program by clicking on a button with a shield on it for example, it usually won't show UAC. – Matt Lyons-Wood Jan 29 '12 at 23:23