Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

RunAs stops working after some days


  • Please log in to reply
13 replies to this topic

#1 Gyzmok

Gyzmok

    Adventurer

  • Active Members
  • PipPip
  • 101 posts

Posted 06 June 2011 - 09:40 AM

Hi all,
I have a strange problem with the RunAs command.
I use Autoit version 16th April 2010 - v3.3.6.1. on a windows 2003 server machine.

This is the code :

If $CmdLine[0] = 0 Then    Exit EndIf RunAs("x1adm_gtt","onprvp.fgov.be","*********",1,"D:\autoit_ged\ged.exe "& $CmdLine[1]) Exit


This code WORKS fine , but only for one - two weeks.
After some days the "D:\autoit_ged\ged.exe " program is never started anymore.
I have to restart the machine and then it works fine again ... for about 7 - 10 days.

I have searched all the "event viewer" logs : nothing.
I have tryed to only restart the "Secondary Logon" service : no solution.

Anyone has an idea ?

Greetings.
D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper







#2 sleepydvdr

sleepydvdr

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 572 posts

Posted 06 June 2011 - 12:11 PM

I assume there's more code that loops this command. Look for anything that may cause the program to exit the loop. Check the memory usage for overflow problems. Also, does the script keep running or does it exit?
#include <ByteMe.au3>

#3 Gyzmok

Gyzmok

    Adventurer

  • Active Members
  • PipPip
  • 101 posts

Posted 06 June 2011 - 02:03 PM

Thanks for your reply.
There isn't more code in this script.
The script is named "GED_START.EXE" and is called from Oracle Forms with :

vrc_cmd := 'd:\autoit_ged\ged_start.exe '||vrc_xml_filename;
HOST(vrc_cmd);


We know for sure that the script is called with the right parameter.

I had to use this "workaround" because the Oracle processes are run as the SYSTEM account.
The SYSTEM account cannot "see" the virtual drives that are used by the GED.EXE
Therefore I use the "GED_START.EXE" to run the "GED.EXE" with a profile that does "see" the mounted virtual drives.

It all works fine for a little more than a week.
Then it suddenly stops working without any error message. (the GED.EXE is simply not run anymore)
After restarting the machine everything is fine again for the next week ...

I checked the "Task Manager" to see the "processes from all users"
None of the scripts stay running all the time.
There seems to be no memory leak problem either. (I'll check that in a couple of days)
I also used the Recovery Tab in the Secondary Logon service Properties and have chosen :
"Restart the Service" on failure.

I know ... this is one of those hard to finds ...

Edited by Gyzmok, 06 June 2011 - 02:10 PM.

D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper

#4 steff

steff

    Seeker

  • Active Members
  • 23 posts

Posted 22 June 2011 - 02:07 PM

I had the same behaviour on one of my Windows 2003 servers: the RunAs has worked for some days, then suddenly it stopped working.
I rebooted the system and then it worked again.
I'm using Autoit v3.3.6.1

Please, have a look at this simple script:

#include <Constants.au3> $output="" $err="" $pid=RunAs ( "administrator", "domain", "Password", 1,'notepad.exe', @ScriptDir, @SW_MAXIMIZE ,$STDERR_CHILD + $STDOUT_CHILD ) ConsoleWrite("Runas pid: " & $pid & " - " & @error& @CRLF) While 1     $output &= StdOutRead($pid)     If @error Then ExitLoop Wend ConsoleWrite("STDOUT Exit from runas: " & $output) $err="" While 1     $err  &= StderrRead($pid)     If @error Then ExitLoop Wend ConsoleWrite("STDERR Exit from runas: " & $err)


When it wasn't working, the returned $pid was 0, no notepad was launched and no STDOUT and STDERR were returned.
Now that it works, the returned $pid is an integer and notepad has been run.

Does anybody understand this behaviour?

Thanks to all replies
stef

#5 boththose

boththose

    þヨⓡᅷ∈℃⊥

  • Active Members
  • PipPipPipPipPipPip
  • 1,518 posts

Posted 22 June 2011 - 03:10 PM

Then it suddenly stops working without any error message.


can both commands be run manually at that point without error (the oracle forms command and the runas inside ged_start)?
Spoiler

#6 rover

rover

    unmutual

  • Active Members
  • PipPipPipPipPipPip
  • 825 posts

Posted 22 June 2011 - 06:31 PM

If $CmdLine[0] = 0 Then    Exit EndIf RunAs("x1adm_gtt","onprvp.fgov.be","*********",1,"D:\autoit_ged\ged.exe "& $CmdLine[1]) Exit



Try using RunAsWait()
from the helpfile regarding the logon_flag: 1 - Interactive logon with profile.

"It is recommended that you only load the user's profile is [sic] you are sure you need it. There is a small chance a profile can be stuck in memory under the right conditions. If a script using RunAs() happens to be running as the SYSTEM account (for example, if the script is running as a service) and the user's profile is loaded, then you must take care that the script remains running until the child process closes."

I see fascists...

#7 steff

steff

    Seeker

  • Active Members
  • 23 posts

Posted 29 June 2011 - 02:01 PM

I found another topic opened in 2008, which describes the same behavior (with some interesting tests), but ends without any solution.

Look here: http://www.autoitscript.com/forum/topic/83887-runas-runaswait-problem/

As described in the topic, I was able to run the above script for 32 times consecutively. At the 33th time, it stopped working.

Other topic related to runas/runaswait issues: http://www.autoitscript.com/forum/topic/124267-runas-exits-occasionally-without-launching-process/

Edited by steff, 29 June 2011 - 02:16 PM.


#8 steff

steff

    Seeker

  • Active Members
  • 23 posts

Posted 01 July 2011 - 07:25 AM

Do anyboady have an idea how to avoid that isuue?

#9 KaFu

KaFu

    Hey, it's just me, KhaFoo...

  • MVPs
  • 3,402 posts

Posted 01 July 2011 - 10:09 AM

"It is recommended that you only load the user's profile is [sic] you are sure you need it. There is a small chance a profile can be stuck in memory under the right conditions. If a script using RunAs() happens to be running as the SYSTEM account (for example, if the script is running as a service) and the user's profile is loaded, then you must take care that the script remains running until the child process closes."

Maybe something like this works?
If $CmdLine[0] = 0 Then     Exit EndIf $iPID = RunAs("x1adm_gtt", "onprvp.fgov.be", "*********", 1, "D:\autoit_ged\ged.exe " & $CmdLine[1]) While ProcessExists($iPID)     Sleep(100) WEnd Exit


Edit: Or of course try using RunAsWait as Rover suggested (didn't see that part :))...

Edited by KaFu, 01 July 2011 - 11:49 AM.


#10 Gyzmok

Gyzmok

    Adventurer

  • Active Members
  • PipPip
  • 101 posts

Posted 24 August 2011 - 02:50 PM

Sorry I gave up on this one.
Maybe it is a "windows 2003 server" only problem.

I took a different (ugly) approach :
changed the GED_START.au3 to a simple "fire and forget" run command.

If $CmdLine[0] = 0 Then    Exit EndIf ;RunAs("x1adm_gtt","onprvp.fgov.be","*********",1,"D:\autoit_ged\ged.exe "& $CmdLine[1]) $val = Run(@ComSpec & " /c " & 'd:\autoit_ged\ged.exe '& $CmdLine[1], "", @SW_HIDE) Exit


In this way the client is not affected by the (short) GED.EXE execution time.
The ugly part :
Since GED.EXE is now executed as the SYSTEM account it does not "see" the virtual drives.
I changed GED.EXE and the resulting output files are now copied on the local server drives.
Now it gets ugly :
An always running autoitscript (GED_COPY) under a USER account with virtual drive access pics up
the output files every minute and dumps them to the right remote location.
This GED_COPY is a "must run all the time".
to achieve this :
a scheduled task starts this script every hour (and "on server startup") to be sure it runs.
Inside GED_COPY on the first line there is:

; If _Singleton("ged_copy.exe", 1) = 0 Then     Exit EndIf ;


Too bad the RUNAS fails after some time.
I did not want to use RUNASWAIT.
It also took too long to really debug a problem that only occurs after several days !

Thanks for the reply's and I am glad not to be the only one having this issue.

Edited by Gyzmok, 26 August 2011 - 08:47 AM.

D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper

#11 roman

roman

    Wayfarer

  • Active Members
  • Pip
  • 74 posts

Posted 14 September 2011 - 07:37 AM

Hi

I can confirm this problem.
I have a Script using "RunAsWait" (AutoIt 3.3.6.0) which did run for approx. 30 days without any problems. Suddenly, the RunAsWait did execute the external program.
I have researched many hours this behavieour and came to the conclusion that "RunAsWait" as well as "RunAs" didn't work.

In the end and for testing, i shrinked my script to one single line; a RunAsWait to start Notepad.exe! And it did NOT work.
So my solution was the recode the script, without using RunAs(Wait).

OS: Windows 2008 R2

Regards, Roman.

#12 veronesi

veronesi

    Seeker

  • Active Members
  • 44 posts

Posted 19 September 2011 - 04:59 PM

I have the same problem.
RunAs is working some time and suddenly it stops working.

Then I have to delete the profile on this computer in the control panel > system > advance settings > advanced tab > profile settings > select the used profile in runas and delete it!

Then it works again.
But this is a ugly workaround and its not automatic...

Any idea to solve this this?
I use the 0 flag for not loading the profile


Veronesi

#13 rover

rover

    unmutual

  • Active Members
  • PipPipPipPipPipPip
  • 825 posts

Posted 19 September 2011 - 07:04 PM

RunAs is definitely limited to running 32 times from a script run as a service. (tested on XP SP3 x86)

The only recourse is to have the service script use RunAs to launch at startup a secondary script in the user profile.
(preferably an uncloseable script with two instances)

Then use named pipes, wm_copydata or _WinAPI_RegisterWindowMessage with sendmessage HWND_BROADCAST for interprocess communication.

If the secondary script is closed by users, hangs or crashes, the service script can monitor this process and close/re-launch it.
This way, RunAs is only used for running the monitoring script in the user profile, with up to 32 re-starts per session.

maybe Sysinternals PsExec would solve this
I see fascists...

#14 veronesi

veronesi

    Seeker

  • Active Members
  • 44 posts

Posted 20 September 2011 - 09:30 AM

In my case, the RunAs command would be called only once per day. And evey night, the pc is rebooting.
Even so I have still this problem.

My script writes every time the PID of the RunAs command in a logfile.
I every time get a PID. Even if the second program will not start! Therefore I can't say: "No it isn't working"....!

I always get a PID, but after some time, the second program doesn't start.
Then I have to kill locally the profile and immediately it's working again.

PS: My script doesn't run as a service. It's a "normal" EXE file

Edited by veronesi, 20 September 2011 - 09:32 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users