jaja714 Posted August 19, 2017 Share Posted August 19, 2017 I have an old program which uses RUN to start a subprocess (lame.exe) and then I monitor that it until completion. It's been working for years like this. Suddenly, this RUN command fails to create the subprocess. The only change I made recently which might be related is that I tweaked Windows (using netplwiz) to log into my PC automatically without password. However, even if I run the program as an admin, the subprocess creation still fails. $hPid = Run($lameCmd, $pjRoot, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) 2017-08-19 12:45:57 | @error 1 2017-08-19 12:45:57 | hPid 0 Link to comment Share on other sites More sharing options...
BrewManNH Posted August 19, 2017 Share Posted August 19, 2017 First thing I'd do is change @SW_HIDE to @SW_SHOW and see what errors you're getting. Second, check that the $lamecmd contains what you expect it to If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jaja714 Posted August 20, 2017 Author Share Posted August 20, 2017 BrewManNH, thanks for the suggestion but there is absolutely nothing wrong with the lame command. It has been stable for many years. Also, changing SW_HIDE to SW_SHOW will do nothing. Remember, the subprocess is NOT getting created, so there is nothing to hide or show. Finally, while the subprocess is NOT getting created, the LAME command is executing as part of the main process. When it is finished, AutoIT displays the results in an AutoIt window. There are no errors. It works perfectly. Link to comment Share on other sites More sharing options...
Danp2 Posted August 20, 2017 Share Posted August 20, 2017 Can you launch any program using Run? Try running the example script in the help file. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kosamja Posted August 20, 2017 Share Posted August 20, 2017 If Run doesnt work, try ShellExecute Link to comment Share on other sites More sharing options...
jaja714 Posted August 20, 2017 Author Share Posted August 20, 2017 Danp2, kosamja ... remember ... this needs to run as a subprocess whose output can be monitored. So, the example does not apply. Also, I'm not sure ShellExecute subprocess can be monitored. The problem is not the RUN command but, its ability to create a child subprocess. Below, please find the routine which monitors the output. This routine is called immediately after the RUN command. $hPid = Run($cmd, $pjRoot, @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD) lameProgress($hPid, $Title) : : : : : : : : : : : : : : : : Func lameProgress($hPid, $Title) $y = @DesktopHeight / 2 + 225 ProgressOn($Title, 'lame', '0%', -1, $y, $DLG_NOTITLE) Local $line = "" While (ProcessExists($hPid)) $line = StderrRead($hPid) If StringLen($line) > 0 Then For $i = 10 To 99 If StringInStr($line, $i & "%") <> 0 Then ProgressSet($i, Int($i) & '%') Next EndIf WEnd ProcessWaitClose($hPid) ProgressOff() EndFunc ;==>lameProgress Link to comment Share on other sites More sharing options...
Danp2 Posted August 20, 2017 Share Posted August 20, 2017 Fine... can you successfully run the example script for StderrRead? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
jaja714 Posted August 20, 2017 Author Share Posted August 20, 2017 Danp2, well, it runs but it requires quite a bit of modification (Comspec and systemdir point to syswow64) before I can know for sure what the problem is. Suffice it to say, the StderrRead example does not run well as it is published. I get "file not found" and blank msgboxs and all that, so I cannot be sure the subprocess is getting created. I'll try later tonight to get the example working. Link to comment Share on other sites More sharing options...
Danp2 Posted August 20, 2017 Share Posted August 20, 2017 Well, at least it runs. So now you are left to figure out why your existing process has broken. You should confirm the contents of the $cmd variable before calling Run. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
jaja714 Posted August 22, 2017 Author Share Posted August 22, 2017 Ah, the final determination had to do with the 'workingdir' parameter. If it doesn't exist, RUN will fail with a zero pid and error set to 1. Too bad it didn't have its own dedicated error code and I could've face slapped myself a lot earlier. 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