StrawHat
StrawHat

Reputation: 361

Cmd batch file configuration

I am looking for a way to terminate a process and run another one afterwards. This should be done in the same batch file. And the only way to terminate the process is to press CTRL + C and then say Y afterswards.

So the thing I want is the batch file to do is to automatically; CMD: CTRL + C CMD: Y

call x.exe

So my question is how do I programatically do these step in batch script?

Any kind of help is appreciated!

Upvotes: 0

Views: 115

Answers (1)

user8555495
user8555495

Reputation:

To do this, first, use the command taskkill. This will terminate the process you specify in the file's code. If that does not work, try putting one of the parameters given when entering taskkill /?.

/S    system           Specifies the remote system to connect to.

/U    [domain\]user    Specifies the user context under which the
                       command should execute.

/P    [password]       Specifies the password for the given user
                       context. Prompts for input if omitted.

/FI   filter           Applies a filter to select a set of tasks.
                       Allows "*" to be used. ex. imagename eq acme*

/PID  processid        Specifies the PID of the process to be terminated.
                       Use TaskList to get the PID.

/IM   imagename        Specifies the image name of the process
                       to be terminated. Wildcard '*' can be used
                       to specify all tasks or image names.

/T                     Terminates the specified process and any
                       child processes which were started by it.

/F                     Specifies to forcefully terminate the process(es).

Secondly, use the call command. Because I have never been in a situation where I had to use this command in my whole life, my definition may not be 100% correct. Sorry.

The call command is used to execute another batch-file. It has to be used in like this: CALL [drive:][path]filename [batch-parameters]. Batch-parameters are used to specify important information required by the file. If you have file extensions enabled, the call command accepts labels as the target.

Here you go.

Upvotes: 1

Related Questions