Sign in to follow this  
Followers 0
Diverge

Printing dos text to text file

7 posts in this topic

#1 ·  Posted (edited)

I'm trying to run a dos command and have the results written to a text file. For example, in dos, i can type: help >c:\test.txt and the results would be stored in a text file named t.txt on the root of the c: drive. In autoit i've been using: RunWait("help > d:\t.txt","", @SW_MAXIMIZE).

I've tried everything i can thing of to try to get this to work, the only way i can do it is to make batch files and have my script run them. But i would like to have everything incorporated into my script.

Is it possible to use the ">" for autoit run and runwait commands? Or any other ideas or suggestions i could try (besides having the script write the batch file, then excute it and then delete the batch file when done)?

Edited by Diverge

Share this post


Link to post
Share on other sites



Lookup _FilePrint in the help file.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Lookup _FilePrint in the help file.

Thanks for the quick reply. I looked in the helpfile for that command, but didn't find it. Is it something added in a newer version of Autoit and SciTe?

Share this post


Link to post
Share on other sites

Have you tried Run(@Comspec & ' /c ' etc)... with the > file.txt ?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

RunWait(@ComSpec & ' /c dir>"c:\output.txt"',"",@SW_HIDE)
thanks, using the above command worked. I had tried to use this command too, but used it incorrectly i guess.

this is the actual file i was trying to capture the results of:

RunWait(@ComSpec & ' /c "d:\devcon.exe find *PID_2228> d:\FindDev.txt"',"",@SW_HIDE)

it looks for the device ID (actually product ID) of a particular usb device, and i have another portion of my script trigger when it finds the device i am looking for (when it is plugged in). I'm automating my work :lmao:

Edited by Diverge

Share this post


Link to post
Share on other sites

The 2 things I found with doing this are assuring your working directory is where you expect it to be when calling a dos command, and paying attention to when dos needs "s p a c e s" quoted, so you use ' on the outside, and " on the insides.

later,

Sul

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