duckling78 Posted October 30, 2008 Share Posted October 30, 2008 Is there a way to programmatically elevate a process as needed? I am looking for functionality like how Windows Task Manager has the UAC shield on the button and gives a UAC prompt after clicking on the "Show processes from all users" button. #RequireAdmin elevates the process right when the script is initialized, but sometimes programs don't always need elevation (such as Task Manager without looking at all users processes) and that brings unnecessary UAC prompts. Basically, I have a process monitoring script, but one of the things it monitors is process specific network usage using "netstat -b". This is the only thing that requires elevation in the script, but in general people won't always need to have this turned on an the UAC prompt is annoying. I'd like some kind of functionality so I can elevate the process in the middle of running as needed. I'd guessing it'd be optimal if it could be implemented in the following way: If Not IsAdmin() Then MsgBox(0, "This program requires elevation.", "Click OK to elevate the script.") RequestElevation() ;<-- This is the function I'd like! EndIf A workaround to doing this may be something like have two scripts with the first without the #RequireAdmin keyword and the second being called from the first with the #RequireAdmin keyword, but that leads to other issues (I have updating code that would need to support this, etc). Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 30, 2008 Share Posted October 30, 2008 Many questions like this have come up before. It's just not doable at a user level. Link to comment Share on other sites More sharing options...
Glyph Posted October 31, 2008 Share Posted October 31, 2008 (edited) Try the runas() command? Not sure if that's wha you mean. Probably not because you want to change the elevation midway through the program? Edited October 31, 2008 by Glyph tolle indicium Link to comment Share on other sites More sharing options...
duckling78 Posted October 31, 2008 Author Share Posted October 31, 2008 Probably not because you want to change the elevation midway through the program?I actually do want to elevate midway through the program.If the user enables network tracking (uses "netstat -b" which requires elevation), and clicks "Apply", then it will elevate the process at that point if not IsAdmin().Is this possible? Link to comment Share on other sites More sharing options...
ProgAndy Posted October 31, 2008 Share Posted October 31, 2008 (edited) This is not possible with AutoIt. In Delphi, you need a Com-Object do to this... http://developersoven.blogspot.com/2007/02...-part_3659.htmlBut you can add the UAC in the manifest, so you're only questionec on Vista, not on XP -> http://community.bartdesmet.net/blogs/bart...ing-mt.exe.aspxMicrosoft supposes to split your app in 2 exe or exe + service Splitting an Application into Standard User and Administrator Components Edited October 31, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
duckling78 Posted October 31, 2008 Author Share Posted October 31, 2008 Er, I found a workaround just in case anyone is interested.http://technet.microsoft.com/en-us/sysinte...s/bb897437.aspxSysinternals TCPView does not require elevation so this will work around my problem of needing elevation in the first place. Yay The command I'll be parsing will probably be: tcpvcon -c -n (process.exe) Link to comment Share on other sites More sharing options...
duckling78 Posted October 31, 2008 Author Share Posted October 31, 2008 Here is an example script of TcpView parsing implemented if anyone was interested: http://www.autoitscript.com/forum/index.php?showtopic=83643The above does not require elevation in Vista and uses TcpView (tcpvcon.exe which is console version). 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