Jump to content

Waiting the end of a DOS command


Recommended Posts

Hello

I'm looking for a way to tell the script "Wait until this DOS command ends", maybe waiting for the prompt. Can I do that (the problem is that I use Sleep() function to wait the end of a copy, but the delay can be higher with many files or big files to copy, and I want it to be the smaller possible).

Thx for suggestions

Link to comment
Share on other sites

RunWait(@ComSpec & " /c " & "commandName")

Edit: Beat me Helge :(

<{POST_SNAPBACK}>

Are you sure of the way you wrote the command? Because I used

RunWait(@ComSpec & " /c copy d:\folder\* n:\folder\")
(saw that in the help file) and it didn't work...
Link to comment
Share on other sites

What I wrote is from the help file... Try this...

#Include <process.au3>
_RunDOS("copy d:\folder\* n:\folder\")

Or

Run(@ComSpec & ' /c copy d:\folder\* n:\folder\', "", @SW_HIDE)

Edit: Just tested

RunWait(@ComSpec & " /c copy d:\folder\* n:\folder\")

Does work, you probably have the parametres set not to create the folder if it doesn't exist. Type "help copy" in CMD and look at them, or you can simple create the folder "N:\Folder" prior to copying.

Edited by Burrup

qq

Link to comment
Share on other sites

What I wrote is from the help file... Try this...

#Include <process.au3>
_RunDOS("copy d:\folder\* n:\folder\")

Or

Run(@ComSpec & ' /c copy d:\folder\* n:\folder\', "", @SW_HIDE)

Edit: Just tested

RunWait(@ComSpec & " /c copy d:\folder\* n:\folder\")

Does work, you probably have the parametres set not to create the folder if it doesn't exist. Type "help copy" in CMD and look at them, or you can simple create the folder "N:\Folder" prior to copying.

<{POST_SNAPBACK}>

The folders do exist. Thank you for the code, I m going to test.
Link to comment
Share on other sites

OK it works. But with this syntax, how do i do to add a second command in the same cmd.exe windows?

Is there better than

RunWait(@ComSpec & " /c " & "copy n:\soft\matlab\* d:\thore\matlab {ENTER} t {ENTER}")
(if this code is possible)

EDIT : Probleme fixed (no need to add 't' to overwrite old files), but I'm still interested in the answer to the question how to execute successively 2 dos command, when the second depends on the result of the first (without closing the cmd.exe window)

Edited by 440LVB
Link to comment
Share on other sites

I'm still interested in the answer to the question how to execute successively 2 dos command, when the second depends on the result of the first (without closing the cmd.exe window)

Create a batch file. Or the StdIO features in the latest AutoIt beta version might work....
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

UP

Batch works but is there a simpler way?

This kind of command doesn't work :

RunWait(@ComSpec & " /c " & "copy n:\soft\matlab\* d:\thore\matlab {ENTER} t {ENTER}")

How can I do when I need to answer (yes/no) a question, without using send() function, in order to avoid mix between the send() message and user typing something on the keyboard.

Link to comment
Share on other sites

Have you looked at the AutoIt FileCopy function?

<{POST_SNAPBACK}>

The problem is no more on the copy (overwrite automatically), but with the cacls function (to change rights) which needs a confirmation (y or n)
Link to comment
Share on other sites

In that case you'll probably have to pipe the answer in within a batch file, don't have an example or remember the exact sytax of what we used at work

but seems like was something like

@echo y|command

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

In that case you'll probably have to pipe the answer in within a batch file, don't have an example or remember the exact sytax of what we used at work

but seems like was something like

@echo y|command

<{POST_SNAPBACK}>

Hm OK but this solution requires a batch file. No autoIT command to say "execute this command in the open cmd.exe window", without using Send() ? Edited by 440LVB
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...