Sign in to follow this  
Followers 0
karmayogi

RunAs exits occasionally without launching process

4 posts in this topic

#1 ·  Posted (edited)

Hello

I have a small piece of AutoIt code that essentially invokes a batch file using the RunAs call.

The exe that I create out of this script is being invoked from a Windows Service

on a Windows 2003 box.

Every once in a while the RunAs fails to launch the process and returns back with various garbage return codes and I can see that

once it goes into such a state no matter what I do or what command I try to launch, it is stuck.

The only way to recover is to actually restart the machine.

Has anyone encountered this issue before?

I can recreate this on any 2003 machine after a few runs. Also I have tried this using AutoIt version: 3.3.0 and 3.3.6.1. Both exhibit the same behavior.

This is my code sample

Local $pid = RunAs($sUser, $sDomain, $sPassword, 0, @ComSpec & " /c " & """" & $sCmd & """", $sTempDir, @SW_HIDE, 0x10)
Local $perrCode = @error
Local $retVal = ProcessWaitClose($pid, $processTimeout)
$errCode = @extended

Appreciate any pointers /help

Thanks

Yogi

[[update 01/21/2011]]

After quite a bit of digging and process level exploration, I think the RunAs function in AutoIt is leaving behind some resource and clogging up the machine. Thats why after a few runs, I see the machine not able to launch any more processes as another user. Is there a way I could look at the source code for the RunAs feature to see if I can help troubleshoot and fix this issue?

Edited by karmayogi

I came, I saw and I copied.

Share this post


Link to post
Share on other sites



You've used some wrong command in this code which are not created by Autoit.(e.g.@extended)

And your Script is Uncompleted too.

Use another element.


Visit HugeSoft(TM) To Get Any Coding Help or Anything

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

[[update 01/21/2011]]

After quite a bit of digging and process level exploration, I think the RunAs function in AutoIt is leaving behind some resource and clogging up the machine. Thats why after a few runs, I see the machine not able to launch any more processes as another user. Is there a way I could look at the source code for the RunAs feature to see if I can help troubleshoot and fix this issue?

#DarkNight... sorry buddy your answer did not make any sense to me. @extended is an autoit construct by the way

Edited by karmayogi

I came, I saw and I copied.

Share this post


Link to post
Share on other sites

Resource leak is very obvious. You are using STDIO redirection but fail to actually trigger any condition which will allow the streams to close. The streams can automatically close if it is detected they are no longer used. This condition is not met. You can forcibly close the streams by using StdioClose() which is not present in your code.

There's no AutoIt bug here, only poorly written code that ignores the documentation.

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