tesmc
asked on
how to end & restart process via a batch file.
I want a simple batch file that will kill a process and then restart that same process.
right now i'm doing it via 'services' window but i want it via a batch file.
i'm testing this with notepad.exe before moving forward with an actual service. not sure if coding would be diff with a service versus an application.
but for my notepad test i have
TASKKILL /F /IM "notepad.exe"
this kills notepad, but then how do i reopen a new notepad? and would these steps be same for a service?
right now i'm doing it via 'services' window but i want it via a batch file.
i'm testing this with notepad.exe before moving forward with an actual service. not sure if coding would be diff with a service versus an application.
but for my notepad test i have
TASKKILL /F /IM "notepad.exe"
this kills notepad, but then how do i reopen a new notepad? and would these steps be same for a service?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
bminker:
your example helped a lot. however, sometimes my process just hangs when i do it via the services window. so i have to forcefully kill it via task manager, i'm trying to incoporate using a taskkill and net start but although i'm able to successfully kill the process, i can't restart it back up
TASKKILL /F /IM "temp.exe"
Net Start "TEMP Server"
if i do this it works:
Net Stop "TEMP Server"
Net Start "TEMP Server"
but i want to forcefully kill this service & then start it back up.
your example helped a lot. however, sometimes my process just hangs when i do it via the services window. so i have to forcefully kill it via task manager, i'm trying to incoporate using a taskkill and net start but although i'm able to successfully kill the process, i can't restart it back up
TASKKILL /F /IM "temp.exe"
Net Start "TEMP Server"
if i do this it works:
Net Stop "TEMP Server"
Net Start "TEMP Server"
but i want to forcefully kill this service & then start it back up.
The question becomes why does your service hang? All services should start and end gracefully. Would recommend you write some debugging code to the sys log to find out what's going on.
ASKER
ged325:
sometimes it just states that the program didn't end in a timely manner and then just takes extra longer to close . that's why i wanted to just forcefully close it.
sometimes it just states that the program didn't end in a timely manner and then just takes extra longer to close . that's why i wanted to just forcefully close it.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you would like to kill a Windows Service, use the Net Start/Net Stop/Net Restart/Net Resume etc...