Jump to content
Sign in to follow this  
Skitty

Run(@ComSpec & " / c " ~ application hangs

Recommended Posts

Skitty

Im running a program using this command~

Run(@ComSpec & ' /c "' & $ProgPath & '" -default',"",@SW_HIDE)

And to my horror autoit treats this as if I were to use RunWait, how can I prevent autoit from waiting for the program to close which is not supposed to close anytime soon while still running it from the command line? :oops:

Edited by THAT1ANONYMOUSEDUDE

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites
UEZ

I assume the application behind $ProgPath is not closing.

What is behind $ProgPath?

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
Skitty

Just another script I've got set up to monitor some stuff, the problem really is that I would expect that autoit would just run the program and continue execution unlike "runwait", I've stumbled into this behavior before and ignored it using another method but this time I really want to be able to execute an app from the command line without showing the command line and having the cmd.exe process exit after executing it and not stay there aiting for the app it ran to close, as it won't close anytime soon..


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites
Skitty

Well, it basically behaves the same way with anything you run via @Comspec, and now that I read up on its switches "which I should have done before", I realize that the /c switch makes the command prompt stand idly by until the program it executed has finished, I would have expected there to be a switch to change this behavior as well but it seems that no matter what you do, the command prompt will always wait for a command it executed to finish, including programs it has executed, this is weird.

I'm using AutoIt v3.3.8.1 but this seems to happen with any version.

In example~

Run(@ComSpec & ' /c "' & @SystemDir & 'taskmgr.exe"',"",@SW_HIDE)

running that will make autoit pause until you close task manager, I would have thought the run() function would just run the command and continue it's execution but that's not how it works as I see..

Edited by THAT1ANONYMOUSEDUDE

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites
Jos

The Run() function returns fine, but what you probably experience is that the Shelled application is a child of the AutoIt3 task and SciTE "thinks" your script isn't finished.

Run this and see you get the taskid returned immediately.

$rc = Run(@ComSpec & ' /c "' & @SystemDir & 'taskmgr.exe"',"",@SW_HIDE)

ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $rc = ' & $rc & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Skitty

The run Func returns fine, but what you probably experience is that the Shelled application is a child of the AutoIt3 task and SciTE "thinks" your script isn't finished.

Run this and look down your Taskmanager for CMD.EXE with the returned TASKNR;

$rc = Run(@ComSpec & ' /c "' & @SystemDir & 'taskmgr.exe"',"",@SW_HIDE)

ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $rc = ' & $rc & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

I felt so stupid when I opened process explorer, ran my program again and noticed it was actually scite waiting for the program to close...

I should have looked closer when doing this..

Local $PID = Run(@ComSpec & ' /c "' & $ProgPath & '" -Default',"",@SW_HIDE)
   Sleep(3000)
   ProcessClose($PID)

This seems to work only the autoit3wrapper seems to stay alive afterwards.

Edited by THAT1ANONYMOUSEDUDE

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites
Skitty

This is only when you run it from within SciTE so is this anything you need to worry about?

Nope, not really, aside from the inconvenience of having to manually terminate the autoit wrapper when testing, everything's fine I guess, thank you for the effort/help :oops:


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites
Jos

Had a closer look and have adapted AutoIt3Wrapper to terminate when the shelled AutoIt3.exe has ended avoid it to wait for any shelled task with Run.

Try the current Beta Autoit3Wrapper.

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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  

×