Hi there, I have recently put together a net send messenger in a .bat file for a program of mine.
I would like to make it so, if the "net start messenger" line fails/has an error,
It echo's " messenger service is currently disabled on your computer. press F1 for instructions to enable this service."

anyone know how to code this?

Recommended Answers

All 3 Replies

After the command, put echo %ERRORLEVEL% And observe the values printed in various outcomes.

You can test this variable with if/else when you know the values it can have.

In my opinion, the easiest way to do this is simply:

net start messenger || echo Messenger service is currently disabled on your computer. Press F1 for instructions to enable this service.

As opposed to && which would run the second command (the echo) only if the first command succeeds, || will run the second command only if the first command fails.

In my opinion, the easiest way to do this is simply:

net start messenger || echo Messenger service is currently disabled on your computer. Press F1 for instructions to enable this service.

As opposed to && which would run the second command (the echo) only if the first command succeeds, || will run the second command only if the first command fails.

thankyou! thats exactly what i was after.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.