Reading Results From CMD window

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
krash2501
Newbie
Posts: 15
Joined: Thu Jul 21, 2016 7:04 pm

Reading Results From CMD window

Post by krash2501 » Thu Jul 21, 2016 7:07 pm

I am looking for a way to grab the results from a CMD text window. I have my script send a command and in return I get either TRUE or FAULSE

I tried gettextatpoint and the other get text options but it never comes back with a result.

any ideas?

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Reading Results From CMD window

Post by JRL » Thu Jul 21, 2016 7:25 pm

Have you tried running the DOS command from within Macro Scheduler and redirecting the results to a text file. You can then read then delete the file.

Code: Select all

Let>RP_Wait=1
Let>RP_Windowmode=0

RunProgram>cmd /c dir c:\*.* > %temp_dir%CDriveList

ReadFile>%temp_dir%CDriveList,vData
DeleteFile>%temp_dir%CDriveList

MDL>vData

krash2501
Newbie
Posts: 15
Joined: Thu Jul 21, 2016 7:04 pm

Re: Reading Results From CMD window

Post by krash2501 » Thu Jul 21, 2016 7:39 pm

That would work but I am running a program from the command window so I can't send commands that way. I need to find a way to capture the text from the cmd window.

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Reading Results From CMD window

Post by JRL » Fri Jul 22, 2016 4:40 am

There is a method to put Command Window text to the clipboard. You could just automate that series of steps.

1 - Right click on the window client area.
2 - pick "Mark" from the menu.
3 - Hold the shift key and arrow right then down to highlight the text
4 - Press Enter to put the highlighted text to the clipboard.
5 - use GetClipBoard> to put the text to a variable.
6 - Parse to acquire your answer.

User avatar
Djek
Pro Scripter
Posts: 147
Joined: Sat Feb 05, 2005 11:35 pm
Location: Holland
Contact:

Re: Reading Results From CMD window

Post by Djek » Fri Jul 22, 2016 12:14 pm

maybe this wil help you:

Code: Select all

//run dos
Let>RP_Wait=2
Let>RP_Windowmode=1
RunProgram>cmd

wait>1
//focus it
SetFocus>c:\Win*
//run dos program
sendtext>dir c:\*.*
Press ENTER

wait>1
// now grab text from program
gettextinit
GetWindowTextex>c:\wind*,vData
MDL>vData
of course you dont have to start the dos program if its allready started, but its just to show you the example,

kind regards,
Djek

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts