Jump to content
Sign in to follow this  
fly

Hold command prompt open while my script is running?

Recommended Posts

fly

I'm calling my autoit script via command line (sometimes, as it also has a GUI). When I call it, the program starts and immediately returns control to the CMD window. How can I make it hold the cmd window until my program exits?

Share this post


Link to post
Share on other sites
Airwolf

I'm calling my autoit script via command line (sometimes, as it also has a GUI). When I call it, the program starts and immediately returns control to the CMD window. How can I make it hold the cmd window until my program exits?

Are you trying to hide the command prompt window while the script is running? If so, you'll need to use WinSetState() with the @SW_HIDE flag.

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt

Share this post


Link to post
Share on other sites
fly

Are you trying to hide the command prompt window while the script is running? If so, you'll need to use WinSetState() with the @SW_HIDE flag.

No, I'm just trying to hold the command prompt so that it doesn't continue on in my batch file until the Autoit program has finished...

Share this post


Link to post
Share on other sites
k3v

a little messy, but...

run("cmd")
dim $mycommand = "dir c:{ENTER}"
sleep(250)
send($mycommand)

Share this post


Link to post
Share on other sites
fly

a little messy, but...

run("cmd")
dim $mycommand = "dir c:{ENTER}"
sleep(250)
send($mycommand)
I don't understand that...

Share this post


Link to post
Share on other sites
ProgAndy

Do you compile with AutoIt3Wrapper?

Then use: #AutoIt3Wrapper_Change2CUI=y


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
Eigensheep

What you're actually dealing with is a need for a command in the CMD environment not autoit. This should do the trick, please let me know either way:

CODE
start /wait /b call "Path to program here"

Obviously replace "Path to program here" with the path. I haven't fully tested the command, but it works with all the .au3 and .exe files i've tried.

Edited by logicBird

Share this post


Link to post
Share on other sites
fly

Do you compile with AutoIt3Wrapper?

Then use: #AutoIt3Wrapper_Change2CUI=y

Will that still allow me to use GUI functions?

What you're actually dealing with is a need for a command in the CMD environment not autoit. This should do the trick, please let me know either way:

CODE
start /wait /b call "Path to program here"

Obviously replace "Path to program here" with the path. I haven't fully tested the command, but it works with all the .au3 and .exe files i've tried.

I could do that, but I'd rather have the syntax the same so that I don't confuse my coworkers too much...

Share this post


Link to post
Share on other sites
cartman380

Will that still allow me to use GUI functions?

I could do that, but I'd rather have the syntax the same so that I don't confuse my coworkers too much...

When you say you're running from the command line, do you mean you're doing a start -> Run -> "script name here".exe?

Or are you actually using a command prompt / cmd.exe?

Share this post


Link to post
Share on other sites
fly

When you say you're running from the command line, do you mean you're doing a start -> Run -> "script name here".exe?

Or are you actually using a command prompt / cmd.exe?

Im running it from cmd.exe

Share this post


Link to post
Share on other sites
cartman380

Im running it from cmd.exe

If you're just running from cmd.exe in your script you could use the WinSetState like so.

WinSetState("cmd.exe", "", @SW_DISABLE)
MsgBox(0, "Wait", "You may use command prompt window again when program is finished running", 5)
; program stuff here
WinSetState("cmd.exe", "", @SW_ENABLE)

I'm not sure if that is what you want, but it's what I could think of to wait until your program is done.

Share this post


Link to post
Share on other sites
TurionAltec

ProgAndy's advice is the best, that will compile the script as console app. You can still do all the GUI stuff you want and it can be called in normal ways

Consequently you can also use ConsoleWrite() to have text show up in the cmd window that called autoit. Useful for showing messages.

The only other real option is calling "Start /wait script.exe" from a Batch file or the command prompt.

Share this post


Link to post
Share on other sites
fly

ProgAndy's advice is the best, that will compile the script as console app. You can still do all the GUI stuff you want and it can be called in normal ways

Consequently you can also use ConsoleWrite() to have text show up in the cmd window that called autoit. Useful for showing messages.

The only other real option is calling "Start /wait script.exe" from a Batch file or the command prompt.

Gotcha. Thanks again then guys!

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  

×