Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 566
  • Last Modified:

Use NET start

How to use net start command to work only if service is not running ?

when service already run; it will give an error message (already started)  how to hide this error ?

i want to have batch file.


Thanks
0
Deyhim
Asked:
Deyhim
1 Solution
 
QlemoC++ DeveloperCommented:
The "stupid" approach, which is neverless the fastest and easist, is to issue the start command and suppress any error output:

net start MyService 2> nul > nul

If it is started already, nothing happens. No output shown and no error reported.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now