How to set a task in the scheduler?

There is a task in task scheduler - at startup run the program and repeat every 3 hours. The option "do Not launch new instances" (Do not start new instance). The action has the form:
C:\Windows\System32\cmd.exe /C start /WAIT /AFFINITY 2 C:\Scripts\Parser.exe


So - the task every 3 hours starts a new instance of the program. Tried in settings to put a "Stop current task"(Stop the existing instance) - still a new process is started, and the old one continues to work.
To do both at the same time was launched only one mission?
June 14th 19 at 20:27
3 answers
June 14th 19 at 20:29
In the first line of the batch file add:
taskkill /f /im parser.exe
June 14th 19 at 20:31
start C:\Scripts\Parser.exe and not cmd
The program is very much server load, it is necessary to limit the process to only one core /AFFINITY 2 - paul_Harb commented on June 14th 19 at 20:34
If you start a CMD - shell starts your task and close.
When you restart -open instance of the command interpreter does not, then you can run.
And what sort of processes launched cmd during operation, no checks.

Output -
1)do Not close cmd yet the process.
2)to independently Control the process in its logic.
3)to directly Launch the desired process.

it is necessary to limit the process to only one core /AFFINITY 2
What prevents the startup parameters of the script to point directly in the scheduler? - earl.Weissnat commented on June 14th 19 at 20:37
Hmm... How would you say... not close cmd I key is specified, /WAIT
cmd starts, starts the exe with the desired parameters and waits until that completes.
However, 3 hours later start another cmd...

In fact, all these parameters are specified in the scheduler. Start immediately parser.exe without cmd with the correct bindings to the core I can't. - paul_Harb commented on June 14th 19 at 20:40
June 14th 19 at 20:33
If this mechanism is not working, write a simple batch file which will insert the job.
The batch file does the following:
1. check for the file-flag (any empty file in any directory) if the file is there - the task is already running, exit.
2. file creation flag
3. start parser.exe
4. delete a file-flag

The downside is that there may be situations when jobs there, and the flag file will not be deleted. In such cases you will have to remove it manually ...

Another option: in the batch file to check for running process parser.exe if the process is not, then start. To check processes you can use tasklist /?

Find more questions by tags cmd/batWindows ServerWindows