Sign in to follow this  
Followers 0
Rorax

I cant get RunAsSet to work..

7 posts in this topic

Not even something simple as this works:

RunAsSet('InsertAdminAccount', @Computername, 'InsertAdminPassword')
  FileDelete('C:\Delete.txt')
RunasSet()

I've tried using " instead of '

I've tried using the computername instead of @computername

I've tried making a different admin account

If I insert @Username and $admin = IsAdmin() and set it to a msgbox it always output the current user and not as admin (since I run it as a user)

And administrator have full NTFS rights to the C:\Delete.txt and users have read only.

I've tried using RunAs in a cmd window, and that works perfectly with the admin account/password. I cant figure out why it wont work with RunAsSet :S and I run the script from a local directory so no networkshares involved. The Secondary logon service is started, tried several different computers also. I got version 3.2.10.0 of Autoitv3 and also tried to compile it with version 3.2.18.0 (I think it was that at least it wasnt the same version I have).

Any ideas?

Regards,

Rorax

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Not even something simple as this works:

RunAsSet('InsertAdminAccount', @Computername, 'InsertAdminPassword')
  FileDelete('C:\Delete.txt')
RunasSet()

I've tried using " instead of '

I've tried using the computername instead of @computername

I've tried making a different admin account

If I insert @Username and $admin = IsAdmin() and set it to a msgbox it always output the current user and not as admin (since I run it as a user)

And administrator have full NTFS rights to the C:\Delete.txt and users have read only.

I've tried using RunAs in a cmd window, and that works perfectly with the admin account/password. I cant figure out why it wont work with RunAsSet :S and I run the script from a local directory so no networkshares involved. The Secondary logon service is started, tried several different computers also. I got version 3.2.10.0 of Autoitv3 and also tried to compile it with version 3.2.18.0 (I think it was that at least it wasnt the same version I have).

Any ideas?

Regards,

Rorax

Are you on Vista?

EDIT:

FileSetAttribute?

Edited by Bert

Share this post


Link to post
Share on other sites

Are you on Vista?

EDIT:

FileSetAttribute?

Forgot to mention that, no I'm using Windows XP SP2 and will also be using it on some Windows 2000 SP4 machines (not this particular script but a script with RunAsSet)

The file itself doesnt have Readonly or anything like that. With admin rights you can delete it without any problems.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I was hoping you would re-RTFM. But alas, no.

"This function allows subsequent Run and RunWait functions to run as a different user (e.g. Administrator)."

Edited by Bert

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I was hoping you would re-RTFM. But alas, no.

"This function allows subsequent Run and RunWait functions to run as a different user (e.g. Administrator)."

Edit: Since english isnt my native tounge, I'll try to explain it even easier (removed other text I replied with). This is a exact copy of the RunAsSet test script I'm trying to run. I made a new user which is a member of the local administrator group, named the account "a" and set the password to "b" (not member of both users/administrators groups, only administrators).

RunAsSet("a", @Computername, "b")
FileDelete("C:\Delete.txt")
RunasSet()

The file Delete.txt in the root of C: has the following properties:

C:\>attrib delete.txt

A C:\delete.txt

A = Archive

Using Net user a (might not be the same names for things since it show up in swedish for me and I translated it and removed parts I didnt find necessery)

C:\>Net user a

Username a

Memberships *Administratörer (is the swedish name for the administrator group)

NTFS rights on C:\Delete.txt

C:\>cacls c:\delete.txt

c:\delete.txt BUILTIN\Administratörer:F

NT INSTANS\SYSTEM:F

BUILTIN\Användare:R

Explanations:

Administratörer = Local administrator group

Användare= Local user group

F= Full access

R= Read

Trying to start Secondary Logon Service with Net start

C:\>net start "Secondary Logon Service"

Tjänsten är redan igång. (Translated to: Service is already started)

Du kan få mer hjälp genom att skriva NET HELPMSG 2182. (Translated to: You can get more help by typing NET etc)

Now it might be easier to tell me what I do wrong with the above code? Oh and I should say that I compile the script as a administrator, put it locally for another user in the Users group with the NTFS right Read on the scripts exe file and execute it from that user (named Test, not that it mather) Edited by Rorax

Share this post


Link to post
Share on other sites

RunAsSet is only designed to initialise a set of user credentials to use during Run and RunWait operations. Not FileDelete. How much clearer can I make it??

Share this post


Link to post
Share on other sites

RunAsSet is only designed to initialise a set of user credentials to use during Run and RunWait operations. Not FileDelete. How much clearer can I make it??

Thats clear enough. I didnt get that from your quote at first. But that explains a lot. Thank you :)

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