Jump to content

Really need help with Runas


Recommended Posts

I 've only dabbled with Autoit and could really use some help in accomplishing something. I've read through the forums about RUNAsSET but having trouble figuring out the best way to accomplish what I want as simply as possible. I would like the entire proccess to be in one script.

What I want to do is simply delete a shortcut out of the all users startup folder on machines where the user has least privlages. Can anyone help with this. I looked at some of the code that is supposed to have the script launch itself a second time but don't really understand what's going on in the code. Thanks for any help.

Link to comment
Share on other sites

Add this function into your script Fill in values for $user, $domain and $password. The script will restart itself as different privilages and run the rest of the script. OnAutoItStart() function is automatically run 1st by the AutoIt Interpreter. This function can be added anywhere in your script (usually at bottom, out of the way).

Func OnAutoItStart()
    ; Add User name
    Local $user = ''
    ; Add Domain name
    Local $domain = ''
    ; Add Password
    Local $password = ''
    ;
    ; Check incomong parameters
    If Not $CMDLINE[0] Then
        ; No parameters then restart as admin
        RunAsSet($user, $domain, $password)
        Run('"' & @ScriptFullPath & '" /admin')
        RunAsSet()
        Exit
    ElseIf $CMDLINE[1] <> '/admin' Then
        ; Exit script with error code 1
        Exit 1
    EndIf
EndFunc

:D

Link to comment
Share on other sites

Add this function into your script Fill in values for $user, $domain and $password. The script will restart itself as different privilages and run the rest of the script. OnAutoItStart() function is automatically run 1st by the AutoIt Interpreter. This function can be added anywhere in your script (usually at bottom, out of the way).

Func OnAutoItStart()
    ; Add User name
    Local $user = ''
    ; Add Domain name
    Local $domain = ''
    ; Add Password
    Local $password = ''
    ;
    ; Check incomong parameters
    If Not $CMDLINE[0] Then
        ; No parameters then restart as admin
        RunAsSet($user, $domain, $password)
        Run('"' & @ScriptFullPath & '" /admin')
        RunAsSet()
        Exit
    ElseIf $CMDLINE[1] <> '/admin' Then
        ; Exit script with error code 1
        Exit 1
    EndIf
EndFunc

:D

Thanks I will give this a try.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...