#90 closed Bug (Fixed)
RunAs fails for a Limited User if run-as user's Profile is loaded
| Reported by: | DaveF | Owned by: | Valik |
|---|---|---|---|
| Milestone: | 3.2.11.12 | Component: | AutoIt |
| Version: | 3.2.11.0 | Severity: | Blocking |
| Keywords: | beta, runas, profile | Cc: |
Description
Using beta 3.2.11.0 on XP SP2:
If the RunAs function is called in a script by a limited user, the RunAs function will fail if the target run-as user's Profile is already loaded; as in the case that another process has already been invoked with the run-as user's credentials with the option to load the user's profile. The failure occurs whether or not RunAs is called with the flag to force-load the run-as user's profile, and whether or not AutoIt spawned the earlier process that loaded the run-as user's profile.
Example code:
; N.B. MUST BE RUN AS A LIMITED USER TO EXHIBIT FAILURE
; declare yourself
Dim $ourPID, $ourPID0, $ourRead
; Run an initial process as the desired user
; This is only significant in this example in that
; it pre-loads the target user's profile; we could
; have right-clicked a program and chosen to Run As...
; this user and achieved the same effect.
$ourPID0 = RunAs("is", @ComputerName, "smacksmack", 1, @SystemDir & '\notepad.exe', @SystemDir)
; Run child task with option to access STDOUT
$ourPID = RunAs("is", @ComputerName, "youwantanother?", 1, @ComSpec & " /c set", @SystemDir, @SW_HIDE, 2)
; Read the child task's STDOUT output
While 1
$ourRead &= StdoutRead($ourPID)
If @error Then ExitLoop
WEnd
; Display result
MsgBox(0, "Debug", @AutoItVersion & " yields:" & @CRLF & $ourRead)
Attachments (0)
Change History (5)
comment:1 Changed 18 years ago by Valik
- Owner set to Valik
- Status changed from new to assigned
comment:2 Changed 18 years ago by Valik
- Milestone Future Release deleted
comment:3 Changed 18 years ago by Valik
- Severity set to Blocking
comment:4 Changed 17 years ago by Valik
- Milestone set to 3.2.11.11
- Resolution set to Fixed
- Status changed from assigned to closed
Fixed in version: 3.2.11.11
comment:5 Changed 17 years ago by Valik
- Milestone changed from 3.2.11.11 to 3.2.11.12
Fixed in version: 3.2.11.12
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.

I must have forgotten to document it, but you *must* be an admin to use RunAs()/RunAsWait().