开发者

Getting error messages from running different actions in .bat file [closed]

Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 11 years ago.

开发者_运维百科 Improve this question

I am running an automated install of webservice on server, creating user, creating site for the service, creating app pool etc.

I would like to write out errors to a log file, I've found out that "2>>" after each line gets me any errors! But how can I write a line before each errormessage just to categorize from which action the errormsg comes from?

I'm not that keen on dos cmd's so any help is appriciated!

Thanks in advance, Finn.


Posting an outline of your script would be helpful.

Assuming the script looks something like this:

command1 params 2>>logfile

command2 params 2>>logfile

you could modify it like this:

ECHO %DATE% %TIME%: Running command1 params...>>logfile
command1 params 2>>logfile
ECHO %DATE% %TIME%: Running command2 params...>>logfile
command2 params 2>>logfile

That is, if I understood your intention correctly, of course.

DATE and TIME in this case are system environment variables. They are evaluated to the current system date and time respectively. You can omit them, of course. I just thought they wouldn't harm if used with logging.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜