Jump to content
Sign in to follow this  
Juvigy

EXE not working as expected when RUNAS -ed

Recommended Posts

Juvigy

I have an IE page started as another profile. Then i runas my .exe with another user ( right click run as different user).
 When i do that , it doesnt work. It attaches to IE and does some things, but it fails on the _IEAttach. If i run it with the same user which started IE, it works.

Func Attach($atachadres)
    Local $i = 1
    While 1
        $oIE = _IEAttach("", "instance", $i)
        If @error = $_IEStatus_NoMatch Then
            $oIE = 0
            ExitLoop
        EndIf
        If StringLeft(_IEPropertyGet($oIE, "locationurl"),StringLen($atachadres)) = $atachadres Then ExitLoop
        $i += 1
    WEnd
EndFunc

So when Run as - ed  it fails with $_IEStatus_NoMatch.

Any idea why this happens?

Share this post


Link to post
Share on other sites
orbs
22 hours ago, Juvigy said:

It attaches to IE and does some things, but it fails on the _IEAttach

please explain the above. it sounds like it contradicts itself. does it or does it not attach?

22 hours ago, Juvigy said:

Run as - ed

what is the -ed switch? i find no reference to that anywhere.

regardless, RunAs has several modes of operation. ask yourself to what purpose you need to run as another user, and choose the appropriate mode of operation.

 

Share this post


Link to post
Share on other sites
Juvigy

So IE is started by double clicking and running on the PC. Then I have compiled the above function as an EXE file. Then i shift+right click the EXE and choose "Run As different user" and start it with an different user than the user that started IE in the beginning.  When i do that the above code fails to attach with the $_IEStatus_NoMatch error. If i do the same thing, but start IE and then the EXE with the same user - it all works.

Share this post


Link to post
Share on other sites
orbs

not surprising. we are left with this:

On 3/10/2018 at 12:44 PM, orbs said:

regardless, RunAs has several modes of operation. ask yourself to what purpose you need to run as another user, and choose the appropriate mode of operation.

i can give you an example where that is a critical consideration. i maintain a utility that connects to MS Outlook by COM (same method as you try to do with IE), and this utility requires access to a network share that the user does not have. so i RunAs the utility with the /netonly equivalent of AutoIt. thus i have the local user environment accessible and the network share. if i had RunAs using another method (with or without the profile loading and/or environment change), i would have neither.

Share this post


Link to post
Share on other sites
Juvigy

OK, but in what mode of RUNAS will i have access to the IE? And using double click to start something what mode does it run ? Interactive logon with profile?

Share this post


Link to post
Share on other sites
orbs

you will have to experiment and figure it out.

it would be easier to help you if you can clearly state your purpose. why do you think you need to operate IE under a different user account? why must you work with an IE session that was started by another user?

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  

×