Sign in to follow this  
Followers 0
Guest sergio_bzh

console output and DOS cmd execution ?

7 posts in this topic

hi !

I've discovered yesterday AutoIt and it is a revelation for me ! At last an easy scritping methos for windows. o:):):):)

I have already written a few scritps and particularly one script I run from Command prompt window. I have 2 problems :lmao: (i've read the help but find nothing) :

1) How write to the console ? like 'echo' command

2) how to execute a DOS command which is not a file ? 'cd' or 'vol' for example ? I need to get the serial of the partition given by 'vol' command.

Thanks a lot.

Serge

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

hi !

I've discovered yesterday AutoIt and it is a revelation for me !  At last an easy scritping methos for windows.  o:)  :)  :)  :) 

I have already written a few scritps and particularly one script I run from Command prompt window. I have 2 problems  :lmao:  (i've read the help but find nothing) :

1) How write to the console ? like 'echo' command

2) how to execute a DOS command which is not a file ? 'cd' or 'vol' for example ? I need to get the serial of the partition given by 'vol' command.

Thanks a lot.

Serge

<{POST_SNAPBACK}>

I can help with that by way of an example script I gave for screen-scraping the dosbox.

AutoItSetOption("WinTitleMatchMode",4)
Run(@ComSpec & " /c " & "Cmd.exe"); open a dos box
WinWait("classname=ConsoleWindowClass"); wait for it to open
ControlSend("classname=ConsoleWindowClass","","","IPCONFIG -ALL{enter}"); send the command
Sleep(500); wait a bit for the command to finish
WinActivate("classname=ConsoleWindowClass"); make sure that our dos box has focus.
Send("!{space}ES{enter}"); scrape the screen
$clipboard = ClipGet(); put the contents of the clipboard into a variable.
MsgBox(0,"Clipboard", $clipboard); display the contents of our variable.

Now, just change IPCONFIG -ALL to something like VOL and you have the start of what you were looking for.

You can also redirect the contents to a text file instead with VOL > volume.txt

and then tinker with the file reading commands.

Happy scripting!

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Thanks for you quick answer,

it works but not at all : result is not copied in the clipboard :

Send("!{space}ES{enter}");

doesn't seem to scrape the screen. ?

Share this post


Link to post
Share on other sites

might be your version of windows. Open a dos box, hold alt and hit space, then e then s and finally enter. This should select all the text and copy it into memory.

Alternately, most of the time I use command lines I just have it save the result into a text file via the pipe command.

ex:

run(@comspec & ' /c dir >dir.txt') ; creates a text file with the directory output.


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

I think I will do it with redirection as you said.

Thanks

Share this post


Link to post
Share on other sites

sykes when i did what you did my cmd window went really huge and the only way to get out was to type: exit

lol :lmao:


FootbaG

Share this post


Link to post
Share on other sites

sykes when i did what you did my cmd window went really huge and the only way to get out was to type: exit

lol :lmao:

<{POST_SNAPBACK}>

I believe (on US systems) that ALT+ENTER will force the dos box from fullscreen back into windowed mode. Try that next time.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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