Sign in to follow this  
Followers 0
cprowse

Talking to a cmd prompt

7 posts in this topic

Hi all,

I am looking for an alternative to ConsoleWrite that will successfully output when calling a compiled script from a cmd prompt. I have successfully got output going to a log using '_FileWriteLog', but cannot get anything to output to the cmd screen.

Also, I seem to be having trouble getting exit codes to be picked up in the cmd screen. I compiled a script simply with the line:

"Exit 10"

Running this in Scite exits with the error code 10 (as expected) - however, calling the compiled script from a cmd prompt, and then running 'echo %ERRORLEVEL%' returns 0 (zero) every time. Am I just doing something stupidly?

Thanks all - apologies for so many newbie questions

-Chris

Share this post


Link to post
Share on other sites



Lets start basic...

run("cmd.exe")
WinWait("C:\WINDOWS\system32\cmd.exe")
WinActivate("C:\WINDOWS\system32\cmd.exe")
send("test")

If this isn't wat you wanted to do, please give us the script (or the part you have trouble with).

Share this post


Link to post
Share on other sites

Logi,

Thanks for the reply - the problem I am having is getting output into the cmd window (on XP) in which I am calling a compiled script. For example, create a new AutoIT script containing nothing more than:

ConsoleWrite("Printing something to the command line" & @LF)

And run this in an editor such as Scite - you get a nice output in the debug window showing the expected sentence.

However, now compile this script into an .exe. Open a cmd window, change to the directory containing the .exe and run it here. No output is printed - it simply returns from the script.

The ConsoleWrite help says "This does not write to a DOS console." - I'm just looking for an alternative?

Also, if this script were to use the Exit ($error_code) function - could I get the exit code in the cmd window when the script returns? echo %ERRORLEVEL% always seems to print '0'

Kind Regards,

-Chris

Share this post


Link to post
Share on other sites

okay if i understand your problem correctly:

You start the program from the commandprompt but the consolewrite doesn't work...

The ConsoleWrite help says "This does not write to a DOS console." - I'm just looking for an alternative?

This means the consolewrite doesnt write TO a CMD window.

Share this post


Link to post
Share on other sites

Exactly - is there any alternative that I can use that will output to a cmd window?

Kind Regards,

-Chris

Share this post


Link to post
Share on other sites

Thanks for this - not quite sure how I didn't come by that thread myself....

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  
Followers 0