Jump to content

sending command to dos/cmd condole window


weszzer
 Share

Go to solution Solved by computergroove,

Recommended Posts

Hello,

I am new to this program. I'm trying to find a solution for over a month now.

Basically, I have a application (3rd Party) tool that run only on DOS command.

Say the name of the tool is Extract.exe. This tool can be run only on dos C:directoryextract.exe -DATE 30/08/2014 (where " - DATE " is a command to extract the data as per the date given which is entered manually)

I would like to automate this to run everyday say 6am. First the program should be called then it will send or type the date automatically  everyday (so the date must be change daily.)

or

Also is it possible to create a command from auto it to send or call a command like the one below, instead of opening or sending command to the cmnd console/window.?:

" C:directoryextract.exe -DATE 30/08/2014 "

but the problem is once this script run the date should be change daily.

I really appreciate if you guys can guide me on how to do this command.

Thank you

 

Link to comment
Share on other sites

You need to check out the Process Management section of the AutoIt Help file (Run, RunWait, ShellExecute, etc), as well as the FAQ section that deals with @ComSpec, and the section in the User Defined Functions section, that has _RunDOS. I would also check out the sections on Running Scripts and Command-line Parameters. Then there are the multitude of examples both here in GH&S plus Example Scripts forums.

One or more of those approaches should work for you.

Welcome to the Forum!

EDIT

Note, that there is a topic here somewhere, that discusses multiple commands on the same line. In short, where you might have used a pipe "|" character in a batch file or at the DOS prompt, you need to use one or more ampersands "&&". Usually one is sufficient, unless you are needing to deal with the return of the first command, etc.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

TheSaint, Thank you for the guidance.. I am now abel to call up/run the exe file using AutoIt.

Now, I can't see any command to send the current date and time (like dd/mm/yyyy/hh hh for hour) to the cmd/dos window.

Please help..

Thank you..

Link to comment
Share on other sites

at first glance it seems very easy to achieve in just 2 steps:
1) the autoit program could be of just one line like this:

Run("C:\directory\extract.exe -DATE " & @MDAY & "/" & @MON & "/" & @YEAR & "/" & @HOUR)

compile the above script and save it as say "C:directoryMyProg.exe" for example

2) then at dos promt type this command (needs to be typed only one time) to schedule your job for all days of all months:
 

AT 6:00 /every:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 "C:\directory\MyProg.exe"

This dos command should plan to run your autoit program every day at 6:00am, and in turn your program should run the "C:directoryextract.exe" with parameters as required.

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

at first glance it seems very easy to achieve in just 2 steps:

1) the autoit program could be of just one line like this:

Run("C:\directory\extract.exe -DATE " & @MDAY & "/" & @MON & "/" & @YEAR & "/" & @HOUR)

compile the above script and save it as say "C:directoryMyProg.exe" for example

2) then at dos promt type this command (needs to be typed only one time) to schedule your job for all days of all months:

 

AT 6:00 /every:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 "C:\directory\MyProg.exe"

This dos command should plan to run your autoit program every day at 6:00am, and in turn your program should run the "C:directoryextract.exe" with parameters as required.

 

Chimp, many thanks for your help.

From your # 2:

I tried to run the command :

AT 6:00 /every:1,2,3..."C:directoryMyprog.exe" when I press enter says Access Denied

I'm thinking to run this .exe at 6am using Task Scheduler.

Edited by weszzer
Link to comment
Share on other sites

at first glance it seems very easy to achieve in just 2 steps:

1) the autoit program could be of just one line like this:

Run("C:\directory\extract.exe -DATE " & @MDAY & "/" & @MON & "/" & @YEAR & "/" & @HOUR)

compile the above script and save it as say "C:directoryMyProg.exe" for example

2) then at dos promt type this command (needs to be typed only one time) to schedule your job for all days of all months:

 

AT 6:00 /every:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 "C:\directory\MyProg.exe"

This dos command should plan to run your autoit program every day at 6:00am, and in turn your program should run the "C:directoryextract.exe" with parameters as required.

 

Chimp, I just found out that the extract.exe tool did not accept the " " & @MDAY & "/" & @MON & "/" & @YEAR & "/" & @HOUR)"

The tooll didn't recognized this format, The tool is only read the actual date like 30/08/2014 which is manually enter.

so,  the autoit must send the daily date to the command prompt.

I can't figure on how to do this in autoit since everyday is different date that need to send to the command prompt.

Thank you.

Link to comment
Share on other sites

Add some debug code to see if the syntax is exactly how you want it:

$Text = ("C:\directory\extract.exe -DATE " & @MDAY & "/" & @MON & "/" & @YEAR & "/" & @HOUR)
MsgBox(0,"",$Text)

You could also just send the above data to the command prompt to see if it looks right in the command prompt:

Run("cmd.exe")
Sleep(2000)
Send("C:\directory\extract.exe -DATE " & @MDAY & "/" & @MON & "/" & @YEAR & "/" & @HOUR)
Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

 

Add some debug code to see if the syntax is exactly how you want it:

$Text = ("C:\directory\extract.exe -DATE " & @MDAY & "/" & @MON & "/" & @YEAR & "/" & @HOUR)
MsgBox(0,"",$Text)

You could also just send the above data to the command prompt to see if it looks right in the command prompt:

Run("cmd.exe")
Sleep(2000)
Send("C:\directory\extract.exe -DATE " & @MDAY & "/" & @MON & "/" & @YEAR & "/" & @HOUR)

 

Hi computergroove,

Many thanks for your reply. I actually your command. But the problem I got is that this extract.exe does not recognize this  " & @MDAY & "/" & @MON & "/" & @YEAR & "/" & @HOUR)

This 3rd Party does not accept this kind  of code. Only accept the actual date like 30/08/2014.

I don't know if the Autoit can write or create the current date and pass it to the command as SEND command.

what I have found is that the date command is usually show as message. I don't want to create a message box with the date, I just need the date to send to dos-prompt.

Guys need your help..

Thank you.

Link to comment
Share on other sites

  • Solution

 

Add some debug code to see if the syntax is exactly how you want it:

$Text = ("C:\directory\extract.exe -DATE " & @MDAY & "/" & @MON & "/" & @YEAR & "/" & @HOUR)
MsgBox(0,"",$Text)

You could also just send the above data to the command prompt to see if it looks right in the command prompt:

Run("cmd.exe")
Sleep(2000)
Send("C:\directory\extract.exe -DATE " & @MDAY & "/" & @MON & "/" & @YEAR & "/" & @HOUR)

In the above 2 examples I gave before the intention was for you to see if the command that was getting sent to your command prompt from autoit is in the correct format. When I run the second example myself I am getting a command prompt window that says:

c:>extract.exe -DATE 04/12/2014/07

If you were to type the above in your command window manually would it work? If not then what do you want it to say instead? How is the above syntax not correct for your extract.exe?

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

Hi computegroove, the command you gave is now working, it send the current date to the dos/cmd prompt, exactly the same output.

Thank you very much.

Chimp, thank you very much

The Saint, thank you very much

consider this solve..

Many thanks to all..

Edited by weszzer
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...