-2

I am trying to detect if a subprocess in currently running via CMD, But I have no idea how to do that, I know how to detect a normal process, but not a subprocess any ideas?

EDIT: I am running a program, if the program finishes it opens a new window, i want to detect when that window opens

Oleboy555
  • 1
  • 1
  • Please specify. – ender_scythe Nov 06 '16 at 16:48
  • I am running a program, if the program finishes it opens a new window, i want to detect when that window opens – Oleboy555 Nov 06 '16 at 16:51
  • Is the window under a different executable name? If not, Batch can't do that. – ender_scythe Nov 06 '16 at 16:51
  • Is the window not listed in tasklist until it is opened, or does tasklist consider it the same process as the program that opened it? – SomethingDark Nov 06 '16 at 16:53
  • the tasklist considers it to be the same process, the new window is called Succes and i want to check if Succes is open – Oleboy555 Nov 06 '16 at 16:54
  • `wmic` might help: http://www.robvanderwoude.com/wmic.php. – ender_scythe Nov 06 '16 at 16:56
  • what does wmic do? – Oleboy555 Nov 06 '16 at 17:02
  • It checks processes and windows, I suggest clicking the link for a better description. – ender_scythe Nov 06 '16 at 17:15
  • 2
    There is no such thing as a sub process. There are processes or nothing. –  Nov 06 '16 at 17:27
  • there are sub processes, in my case its program ABC that is running, once it has finished task X it opens a new window and that window is in task manager subprocess XYZ, I want to check if XYZ is opened, if so execute command Y – Oleboy555 Nov 06 '16 at 17:48
  • tasklist can filter by window title and image name (executable). – soja Nov 06 '16 at 18:28
  • @Noodles - That depends on your definition of sub-process, even when looking at it from an operating system level. If process A with PID = 123 launches process B with PID = 456, then `WMIC process get` will list B showing ProcessID 456 and ParentProcessID 123. So the OS is aware that B was launched by A, which sounds to me like a sub-process. However, B has no dependency on A (at least from an OS perspective), You can kill A, and B will carry on (and the ParentProcessID is still listed as the now non-existent 123) – dbenham Nov 07 '16 at 13:32
  • Processes record the PID of the process that started the,. That PID may be reused so the information is for interest only and cannot be relied on. Don't make up your own terms. You're talking to adults. –  Nov 07 '16 at 19:32

1 Answers1

0

If the window only shows up when the program closes, then you could check if the program is still running, and if not running, then the window will be shown.

To check if program is running, use one of these solutions:

How to check if a process is running via a batch script

Community
  • 1
  • 1
cyberponk
  • 1,585
  • 18
  • 19