Jump to content

Hold command prompt open while my script is running?


 Share

Recommended Posts

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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...
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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...
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!
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...