none
Batch file: A command that last forever RRS feed

  • Question

  • I have a batch file with few commands

    *************************

    command1

    command2

    command3

    *************************

    if I execute command 2, it will have info massage comes out and it would last forever. So I won't be able to execute command3. 

    [02/Jul/2014:10:10:33] [Info] [CA WebAgent IPC] [3500] [CSmIpcEvent::WaitForEven
    t] Time-out interval elapsed, but the event's state is nonsignaled
    [02/Jul/2014:10:10:33] [Info] [CA WebAgent IPC] [3500] [CSmIpcEvent::WaitForEven
    t] Time-out interval elapsed, but the event's state is nonsignaled
    [02/Jul/2014:10:10:33] [Info] [CA WebAgent IPC] [3500] [CSmIpcEvent::WaitForEven
    t] Time-out interval elapsed, but the event's state is nonsignaled
    [02/Jul/2014:10:10:34] [Info] [CA WebAgent IPC] [3500] [CSmIpcEvent::WaitForEven
    t] Time-out interval elapsed, but the event's state is nonsignaled
    [02/Jul/2014:10:10:34] [Info] [CA WebAgent IPC] [3500] [CSmIpcEvent::WaitForEven

     Now I am doing it spwan a new window to run command 2

    ******************

    command 1

    start cmd /c command 2

    command 3

    ****************

    so that I can run command 3.

    But how can I close the windows of command 2 in the batch script without killing the process that command 2 running

    Is there a way the mother windows can exit the child windows?

    Thanks and regards,
    Eric

    Wednesday, July 2, 2014 4:14 PM

Answers

  • But how can I close the windows of command 2 in the batch script without killing the process that command 2 running

    You can't do it without terminating the process.


    -- Bill Stewart [Bill_Stewart]

    Wednesday, July 2, 2014 4:18 PM
    Moderator

All replies

  • But how can I close the windows of command 2 in the batch script without killing the process that command 2 running

    You can't do it without terminating the process.


    -- Bill Stewart [Bill_Stewart]

    Wednesday, July 2, 2014 4:18 PM
    Moderator
  • Is there a way the mother windows can exit the child window?

    You could invoke your commands from a VBScript where you have a little more flexibility:

    set oWshShell = WScript.CreateObject("Wscript.Shell")
    oWshShell.Run"d:\Tools\Command1.exe", 1, True
    oWshShell.Run"d:\Tools\Command2.exe", 0, False
    oWshShell.Run"c:\Tools\Command3.exe", 0, False

    Use 0 to hide each window, 1 to display it.
    Use True to make the script wait for the command to complete, False to make script move to the next line of code immediately.

    • Proposed as answer by Frederik Long Tuesday, July 8, 2014 8:18 PM
    Wednesday, July 2, 2014 5:14 PM
  • How does hiding the window help if the process continues running?


    -- Bill Stewart [Bill_Stewart]

    Wednesday, July 2, 2014 6:44 PM
    Moderator
  • How does hiding the window help if the process continues running?


    -- Bill Stewart [Bill_Stewart]


    The OP was a little unclear in this regard. Maybe he is annoyed by the console window that remains visible while the process is running. The Run method would get around this problem.
    Wednesday, July 2, 2014 6:52 PM
  • Ah, OK then your answer makes more sense. I was under the impression the OP was asking how to tell a separate process to close without forcibly terminating it. If you are right and he simply doesn't like the console window, then using the Run method is a good solution. He might also just be able to say:


    start "" /min command2

    (minimize rather than hide)


    -- Bill Stewart [Bill_Stewart]

    • Proposed as answer by Frederik Long Tuesday, July 8, 2014 8:18 PM
    Wednesday, July 2, 2014 7:01 PM
    Moderator