Tankman Posted March 19, 2010 Share Posted March 19, 2010 Hi there AutoIt-Community Long time reader (thanks for all the help), first time writer here. I have a problem with #Requireadmin in my script. It happens when u execute it with user privileges and UAC is turned off. I narrowed it down to #Requireadmin, cause the same problem appears when I write a simple script like #RequireAdmin MsgBox(0, "Test", "Test") This script causes Autoit to spawn itself in a loop over and over again. I couldn't even kill the process. I had to restart to make it stop. Once I comment #Requireadmin out it works without a problem. The script works fine with administrator privileges or when UAC is turned on, then it correctly asks me for admin credentials under a user account. I am using AutoIt v3.3.6.0 (also tried it with v3.3.4.0) under Windows 7 Professional x64. I would be very thankful for any help. Link to comment Share on other sites More sharing options...
Tankman Posted March 22, 2010 Author Share Posted March 22, 2010 (edited) Just wanted to say that I had time today to test out my problem on some other operating systems. It was the same at Windows 7 Professional x32 and Windows Vista Business x32. I am curios if I am just unable to install Windows several times or if this is really a bug. Could somebody please try to reproduce this and tell me how it worked? All you have to do is create an account with user permissions, deactivate UAC (restart afterwards, of course) and then run the following script #RequireAdmin MsgBox(0, "Test", "Test") I don't get the MessageBox. As soon as I run the script I see the hourglass flashing constantly and when I check the running processes in the Task Manager I see my script starting and stopping all the time. Again, I have no problem whatsoever when I run the script as an Administrator (naturally) or when UAC is turned on. Edited March 22, 2010 by Tankman Link to comment Share on other sites More sharing options...
Tankman Posted March 24, 2010 Author Share Posted March 24, 2010 Bump Link to comment Share on other sites More sharing options...
MHz Posted March 24, 2010 Share Posted March 24, 2010 The issue is listed in the BugTracker here as an open bug. Link to comment Share on other sites More sharing options...
Tankman Posted March 24, 2010 Author Share Posted March 24, 2010 Well, that teaches me to also search for open bug reports and not only in the forum :-) Thanks for the hint MHz. In the meantime I found a little workaround. When I compile my Script with SciTE and set the Au3Wrapper-Setting "Execution Level" to "Requireadministrator" it works much better. The script doesn't get elevated to Admin under User-credentials when UAC is turned off, but at least it doesn't create an executing loop. Of course it would be most perfect if Users get asked for Adminrights even when UAC is turned off, but it seems that isn't possible. Thanks again. Link to comment Share on other sites More sharing options...
99ojo Posted March 24, 2010 Share Posted March 24, 2010 Hi, maybe a solution: If Not IsAdmin () Then ;little Gui asking for username, password input, O.K and Cancel button and then restart your exe RunAs (@ScriptDir & "\myexe.exe",........) Exit EndIf ;-)) Stefan Link to comment Share on other sites More sharing options...
Tankman Posted March 24, 2010 Author Share Posted March 24, 2010 Hi, maybe a solution: If Not IsAdmin () Then ;little Gui asking for username, password input, O.K and Cancel button and then restart your exe RunAs (@ScriptDir & "\myexe.exe",........) Exit EndIf ;-)) Stefan Hi Stefan Thanks for your post. I never tried it with IsAdmin() cause I read in another forum post that the function doesn't work when UAC is disabled. But I will give it a try tomorrow and report back if it worked. Link to comment Share on other sites More sharing options...
Richard Robertson Posted March 24, 2010 Share Posted March 24, 2010 The manifest based solution is much cleaner than the #RequireAdmin version. By having the executable declare itself as requiring administrative privileges, Windows can display the admin shield and you don't have to worry about the script restarting itself. Link to comment Share on other sites More sharing options...
SKlocke Posted March 29, 2010 Share Posted March 29, 2010 A small addition, as it took me a while to get the manifest based solution to work. Autoit embeds a manifest section into the executable. Its content can be controled with compiler directives (that can be inserted with SciTE AutoIt Wrapper). The directive to require admin rights is #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator. Hope this reply is not out of place, but it took me *quite* some time to realize that I could not and did not have to bind another manifest but set an option. Link to comment Share on other sites More sharing options...
Tankman Posted April 1, 2010 Author Share Posted April 1, 2010 Sorry it took me so long to get back to you guys. I played around with IsAdmin() and found out that the function works even when UAC is turned off. I decided against trying to run the script again with RunAs() and just check if the process is running with Adminrights, if not then I write out an error with MsgBox(). To sum everything up... I created a script that was compiled with SciTE using the AU3Wrapper-Setting #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator and a simple code that checks for Adminrights like If Not Isadmin() Then MsgBox(48,"Error", "Error") Exit EndIf I am satisfied with the way it behaves now, although a properly working #RequireAdmin would still be nice. Link to comment Share on other sites More sharing options...
tonycst Posted September 12, 2013 Share Posted September 12, 2013 Issue no longer exists since who knows what update, but it does for windows 8. I can run applications fine using run command, but somehow application is blocked from drag and drop. Why would microsoft make such a feature anyway. I hope there will be a fix for that caz every single program i run using autoit has drag and drop disabled because of windws 8 security. Even firefox doesnt have spellcheck because of that Link to comment Share on other sites More sharing options...
BrewManNH Posted September 12, 2013 Share Posted September 12, 2013 Talk to Microsoft. For example, start Notepad using right click "Run as administrator", you can't drag and drop into it after that. I'm guessing they do it that way because of security reasons, running a program under Admin credentials might open up security holes. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now