Gyzmok Posted June 6, 2011 Share Posted June 6, 2011 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]) ExitThis 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 Link to comment Share on other sites More sharing options...
sleepydvdr Posted June 6, 2011 Share Posted June 6, 2011 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> Link to comment Share on other sites More sharing options...
Gyzmok Posted June 6, 2011 Author Share Posted June 6, 2011 (edited) 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.EXETherefore 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 June 6, 2011 by Gyzmok 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 Link to comment Share on other sites More sharing options...
steff Posted June 22, 2011 Share Posted June 22, 2011 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 Link to comment Share on other sites More sharing options...
iamtheky Posted June 22, 2011 Share Posted June 22, 2011 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)? ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
rover Posted June 22, 2011 Share Posted June 22, 2011 If $CmdLine[0] = 0 Then Exit EndIf RunAs("x1adm_gtt","onprvp.fgov.be","*********",1,"D:\autoit_ged\ged.exe "& $CmdLine[1]) ExitTry 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... Link to comment Share on other sites More sharing options...
steff Posted June 29, 2011 Share Posted June 29, 2011 (edited) I found another topic opened in 2008, which describes the same behavior (with some interesting tests), but ends without any solution. Look here: 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: Edited June 29, 2011 by steff Link to comment Share on other sites More sharing options...
steff Posted July 1, 2011 Share Posted July 1, 2011 Do anyboady have an idea how to avoid that isuue? Link to comment Share on other sites More sharing options...
KaFu Posted July 1, 2011 Share Posted July 1, 2011 (edited) "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 July 1, 2011 by KaFu  OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Gyzmok Posted August 24, 2011 Author Share Posted August 24, 2011 (edited) 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) ExitIn 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 upthe 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 August 26, 2011 by Gyzmok 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 Link to comment Share on other sites More sharing options...
Roman Posted September 14, 2011 Share Posted September 14, 2011 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. Link to comment Share on other sites More sharing options...
veronesi Posted September 19, 2011 Share Posted September 19, 2011 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 Link to comment Share on other sites More sharing options...
rover Posted September 19, 2011 Share Posted September 19, 2011 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... Link to comment Share on other sites More sharing options...
veronesi Posted September 20, 2011 Share Posted September 20, 2011 (edited) 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 September 20, 2011 by veronesi Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now