Jump to content

EXE not working as expected when RUNAS -ed


Recommended Posts

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?

Link to comment
Share on other sites

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.

 

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

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?

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

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...