0

I want to redirect the statements it puts on the console into a file in windows batch code. I am using the net stop command to stop a service.

When I do this:

net stop SPTimerV4 2>> mylog.log

it appends error text into the file. But it still prints the regular text on the console:

The SharePoint 2010 Timer service is stopping.
The SharePoint 2010 Timer service was stopped successfully.

How can I even redirect this to a file?

Thanks

1

1 Answer 1

3

net stop SPTimerV4 >> mylog.log 2>&1 is what you're looking for.

This works by redirecting all normal output to the log file (the >>) and redirecting error output a copy of the normal output at that moment, which is appending to a file.

Because it redirects to a copy, you can't actually switch them around (eg. 2>&1 1>> mylog.log won't work)

For more information regarding redirection, please look here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.