Disclaimer I'm not familiar with these subjects (services, net
command, and server maintenance in general).
On Windows, the net
command allows to stop and start services, via net stop "<service name>"
and net start "<service name>"
Is it bad practice to run net start "<service name>"
on a service whose status is not checked beforehand?
I understand that I could check the service status, and start it only if the status is stopped
. But if this is not necessary, why complicate things?
I did try to run the command on an already running service, and Powershell simply responded Le service demandé a déjà été démarré.
which might translate to The requested service has already been started.
I did not see any bad side effects, but I might overlook a lot of issues.
Use case would be to make sure that a specific service is indeed running.
This specific service is supposed to start automatically. The server that hosts it is configured to reboot every day at a specific time (I have no way to control this), and on some occasions, the service does not automatically start. So while we are investigating the starting issue, I want to temporarily fix this by automatically (via the task scheduler) starting the service at a certain time after the reboot if it is not already running.