Sign in to follow this  
Followers 0
samkshah

RunAsSet() - Win XP SP2 and Win2k3

8 posts in this topic

Is running RunAsSet() and escalating to admin rights still an issue? I came across this http://www.autoitscript.com/forum/index.php?showtopic=6544 bug report and looks like it has not been updated since long. I am trying to use RunAsSet() in my script to escalate rights to admin account and looks like it does not work.

Am I doing anything wrong or is still an issue? Here is my algorithm:

local $escalaterights

$escalaterights = RunAsSet("adminuser", @LogonDomain, "adminpass", 0)

If $escalaterights = 0 Then
    writeLog("OS does not support RunAsSet function")
    exitewitherr()
EndIf   

If IsAdmin() then 
    writeLog("rights escalated to account: " & @LogonDomain & "\" & @UserName)
else 
    writeLog("could not escalate admin rights")
    exitwitherr()
EndIf

Above code always returns following text in log file:

"rights escalated to account: domain\currentuser" instead of "rights escalated to account: domain\adminuser"

Any idea on why it's not working or any alternative method that I can use?

FYI: This script is for win xp sp2, win 2000 and win2k3 machines. I am using latest version of AutoIT downloaded yesterday - v3.2.2.0 beta

Thank you much,

samkshah

Share this post


Link to post
Share on other sites



FYI: current logged in user also has admin rights. However script does not work if a logged on user does not have admin rights.

Share this post


Link to post
Share on other sites

From the help file under RunAsSet:

This function allows subsequent Run and RunWait functions...

I do not see any "subsequent Run and RunWait functions" in your sample code.

RunAsSet does not escalate the rights for all subsequent lines in a script, just Run and RunWait lines... so you IsAdmin line is not impacted by the RunAsSet line above it.

...or perhaps I do not understand "the rest of your code" that is not shown...


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thanks for quick response. Let me include my complete code in my next post. My requirement is to run entire script as admin user and not only "Run" or "Runwait" commands. Since I am replacing text in a text file which is in "Program Files" directory, I need to run entire script as admin user. I am sorry for my mistake in previous thread where I told that I was using latest version. I now downloaded a latest beta version and still it's an issue.

Thank you much,

samkshah

Share this post


Link to post
Share on other sites

...or something on that order.

I should have searched for that method and posted a link to it in my reply - it has been posted a few times before (probably by you) - anyway, maybe this should be moved to the support forum as it seems to be "no bug".

-MSP-


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

I've added an example for this in the docs for RunAsSet in the new beta.

Good idea - that is why they pay you the big bucks :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0