Wildcard Services restart
Solution 1:
Easy, via Powershell:
Get-service SERVICE* | stop-service -force
Get-service SERVICE* | start-service
Solution 2:
You can use wmic
and SQL-ish wildcard syntax.
From a cmd
console:
wmic service where "name like 'SERVICE%'" call startservice
From a .bat
script:
wmic service where "name like 'SERVICE%%'" call startservice
Available verbs include startservice
, stopservice
, pauseservice
, resumeservice
, and others. Do wmic service call /?
for more info.
Solution 3:
if you want a One Line command,
You can use Restart-Service Cmdlet which is pre built in powershell.
To use Restart-Service simply call the cmdlet followed by the service name:
Restart-Service mysql57
To restart multiple services just specify the name of each service, separated by commas:
Restart-Service mysql57,apache
If you prefer, add the -displayname parameter and specify the service display name (the name shown in the Services snap-in) instead:
Restart-Service -displayname "Mysql 5.7 server"
This Cmdlet accepts wildcard matching as well. To restart all services starting with "mysql":
Restart-Service mysql*