I am writing software to scan through predetermined services and start them if they are stopped. Unfortunately some of the service names have spaces so if i do this:
for %%a in (MSSQLSERVER,SQLSERVERAGENT,Cardinal SPD Delivery Package Service,AuthenticationServiceHost,CommunicationService,CqiProcessorService,IISADMIN,MobileAutmationAgentService,MSMQ) do (
What happens is, it treats the Cardinal SPD Delivery package as three separate services instead of one when i do
net start "%%a"
for example.
The alternative that I found that works is putting the services in a text file and doing
for /f %%a in (services.txt) do(
But I would prefer to do it the first method since it’s a lot cleaner. Any suggestions?
Either double quote all services names and don’t quote
%%ain the call:Or double quote only multiple words and remove the quotes from
%%awhen you call it: