Jump to content
Sign in to follow this  
sandman

How to make your EXE respond to DOS commands.

Recommended Posts

sandman

Here is a very simple method, along with example, to respond to a command typed in a DOS (aka cmd) window. Normally AutoIt cannot do this but now it is very simple to do! Here's an example:

If $cmdline[0] > 0 Then
    If $cmdline[1] = "talk" Then
        $bat = "echo Hello World"
        FileWrite("respond.bat", $bat)
        If Not @error Then
            Send("respond.bat")
            Send("{ENTER}")
        EndIf
    EndIf
EndIf

Although it's kind of messy, it will serve its purpose. If anyone knows of an easier way, please tell me about it.

note: ConsoleWrite(), although it sounds like it would work, is not seen by the DOS commandline window.

this is how it will look:

C:\>myscript respond

C:\>respond.bat

C:\>echo Hello World
Hello World

C:\>

The respond.bat and echo are automated, as you can see in the script above. See, it's not perfect, but it can get the job done. :)

Thanks,

SANDMAN!

:):guitar::)

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites
lod3n

Even better, take a look at PaulIA's method for ACTUALLY writing to the console.

http://www.autoitscript.com/forum/index.php?showtopic=42542

It isn't perfect (the command line returns before the characters are written), but it is the best pure AutoIt implementation that I've seen posted.

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

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  

×