Jump to content

Command Prompt capture for existing window

Recommended Posts


Hi all, I have seen all the examples provided in this forum for command line window contents capture but all of them include running the cmd within autoit.


How can you capture and search for a string within an existing command line window tho that runs seperately and externally from another software? how do i get the id of the cmd window to monitor? doesnt the id change everytime its run?


can i capture/monitor the console window using window title that never changes?





Share this post

Link to post
Share on other sites
Posted (edited)

ok, I am going to post this, solution below:


wmic process get Caption,ParentProcessId,ProcessId

Given a parent PID you can list the immediate children with something like:

wmic process where (ParentProcessId=2480) get Caption,ProcessId


TEST: ok, so I ran a cmd, then explorer from it and notepad. i ran each of the above wmic statements from a cmd window. the second statement will show you the children of the parent and you could capture that and do what you like. In my case, the PID of cmd.exe was 4050 and his children where shown with their PIDs, notpad and explorer and WMIC.exe


Edited by Earthshine
  • Like 2

My resources are limited. You must ask the right questions


Share this post

Link to post
Share on other sites


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