Jump to content

RUN suddenly command not working


Recommended Posts

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

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 Gude
How 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

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

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

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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...