Start a Windows service from a batch script and take appropriate action based on result
问题 I have a .bat script that attempts to start a Windows service at the end. :start_wildfly echo. set /p wildfly_service_name="Enter Wildfly service name: " echo INFO: Starting %wildfly_service_name%... echo. call net start "%wildfly_service_name%" I want to be able to interpret the result of the net start attempt so that I can have my script take the appropriate action if it fails (e.g. if the service is already running, restart it. If the service name is invalid, re-prompt for the name again,