Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I create bat file and run bat file.I want to run the bat file at a specific time interval and stop it after this time.
How to stop running bat file if it is out of the desired time interval.

I want to

1.If how do I calculate that you are in that time period.
2.That time period if the bat file I want to let it stop.


two time between run bat file.other time not run.

What I have tried:

string batfile=""; //batfilepath

//datetime now let bat file work between these two hours.How to write between time
Process p=Process.Start(batfile);

if(now>time2)
{
process.Stop();

}
}
Posted
Updated 9-Nov-19 11:52am
v2
Comments
Richard MacCutchan 10-Nov-19 3:04am    
what is the problem with that code?

1 solution

Process p=Process.Start(batfile);

   if(now>time2)
   {
      p.Kill();
   }
}

But of course that won't be enough, see this CodeProject article for a more elaborate example: Task Scheduler[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900