0

I want to call "net stop MyService" in the pre-build phase of Visual Studio.

It works fine if the service is running, but if it's not running, net stop returns an exit code and then Visual Studio doesn't build my code. From the command line, echo %ERRORLEVEL% returns 2.

Is there a way to make "net stop" return an error code of zero? Or is there a way to make Visual Studio build even if the pre-build phase fails?

I'm used to having a /f "force" parameter that tells a command to do the best it can and not complain if things aren't just right. I can't find anything like that for "net stop".

Maybe I could wrap it in a batch file...?

Dialecticus
  • 16,400
  • 7
  • 43
  • 103
user2258603
  • 65
  • 1
  • 5

1 Answers1

0

Execute exit /b 0 to exit with ERRORLEVEL 0

Dialecticus
  • 16,400
  • 7
  • 43
  • 103