I open a cmd script using
$a = start-process cmd.exe -argumentlist "/c M:\loc\to\file.cmd" -passthru
start-sleep -seconds 5
#Send ENTER KEY
Sometimes the cmd window will take longer than 5 seconds to load from the network, and my ENTER keystroke does not take because the cmd window has not displayed the "press any key to continue" point in the process.
Is there a way I can get my script to wait for the $a process to display that "press any key to continue" text inside the cmd window before sending my ENTER keystroke?