# MSFN Forum: how to capture batch file output in log file? - MSFN Forum

Jump to content

Page 1 of 1

## how to capture batch file output in log file? Rate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.msfn.org/board/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=21611&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1996

• Member
• Group: Members
• Posts: 118
• Joined: 19-September 03

Posted 29 June 2004 - 08:20 AM

For reasons of debugging I would like to capture the output of my installs.cmd and hotfixes.cmd into two logfiles on the desktop ready for inspection after installation finishes. I've tried many ways of doing so but they all have failed

I'm using this command to enable the output to a logfile:
>"%AllUsersProfile%\Desktop\installs.log" "%systemdrive%\install\installs.cmd"

Now it works just fine in the lab but not in a virtual machine. I know the cmdlines.txt and the RunOnceEx section of winnt.sif don't like the commands such as the above so I'll have them call a cmd file with the above method but they won't even start. I've checked for spelling mistakes, folders etc. There must be a way to do this...

How can I log the output of my hotfixes.cmd and installs.cmd?

### #2GreenMachine

• ineXPlicable
• Group: Developers
• Posts: 3,062
• Joined: 22-August 03

Posted 29 June 2004 - 10:49 AM

ECHO START BATCH 1 >> %SYSTEMDRIVE%\GM.LOG
BATCH1.CMD >> %SYSTEMDRIVE%\GM.LOG
ECHO START BATCH 2 >> %SYSTEMDRIVE%\GM.LOG
BATCH2.CMD >> %SYSTEMDRIVE%\GM.LOG
ECHO START BATCH 3 >> %SYSTEMDRIVE%\GM.LOG
BATCH3.CMD >> %SYSTEMDRIVE%\GM.LOG
That should outta work...

### #3996

• Member
• Group: Members
• Posts: 118
• Joined: 19-September 03

Posted 29 June 2004 - 12:44 PM

Thanks GreenMachine,

that surely works, but the problem is simply this: It doesn't seem possible to use commands like this:

>"%AllUsersProfile%\Desktop\installs.log" "%systemdrive%\install\installs.cmd"

or the ones you suggested in the [COMMANDS] section of cmdlines.txt and in the [GuiRunOnce] section of winnt.sif. I've tried using batch files in these sections to call the commands but that didn't work either.

### #4gosh

• gosh 2.0
• Group: Patrons
• Posts: 2,347
• Joined: 03-October 03
• OS:none specified
• Country:

Posted 29 June 2004 - 02:00 PM

If you want to overwrite the existing file:

copy blah.txt > log.txt

If you want to append an existing log file:

copy blah.txt >> log.txt

That's all you do.

-gosh

### #5sleepnmojo

• Advanced Member
• Group: Members
• Posts: 472
• Joined: 02-March 04

Posted 29 June 2004 - 03:42 PM

Do the commands run and the output is just not placed in the log file?

Have you also tried redirecting the stderr output as well? I believe it is >&.

### #6996

• Member
• Group: Members
• Posts: 118
• Joined: 19-September 03

Posted 30 June 2004 - 04:12 AM

I got it to work now. (A nights sleep helps things enormously...)
Apparently, it isn't possible to use the redirect command like this:

>logfile.log batch.cmd

Instead one has to use the old-fashioned command:

batch.cmd > logfile.log

Now that still doesn't work from within winnt.sif and cmdlines.txt so I had them call batch files with the respective commands, turn on @echo in the batch files and abfter fixing some paths it worked like a charm and I am now finding 2 nice log files on my desktop after installation.

Thanks again for the help!

### #7 Guest_zippy_*

• Group: Guests

Posted 30 June 2004 - 04:56 AM

996, on Jun 30 2004, 04:12 AM, said:

Apparently, it isn't possible to use the redirect command like this:

>logfile.log batch.cmd

i'm noob, never find any redirect command like this...
where did this syntax came from?

### #8996

• Member
• Group: Members
• Posts: 118
• Joined: 19-September 03

Posted 30 June 2004 - 05:39 AM

zippy, on Jun 30 2004, 12:56 PM, said:

996, on Jun 30 2004, 04:12 AM, said:

Apparently, it isn't possible to use the redirect command like this:

>logfile.log batch.cmd

i'm noob, never find any redirect command like this...
where did this syntax came from?

I found that syntax here.

### #9 Guest_zippy_*

• Group: Guests

Posted 30 June 2004 - 08:20 AM

thanks for the syntax link...

### #10996

• Member
• Group: Members
• Posts: 118
• Joined: 19-September 03

Posted 30 June 2004 - 09:31 AM

zippy, on Jun 30 2004, 04:20 PM, said:

thanks for the syntax link...

Anytime, zippy. You way also want to check this site for some infos on redirecting batch output.

### #11GreenMachine

• ineXPlicable
• Group: Developers
• Posts: 3,062
• Joined: 22-August 03

Posted 30 June 2004 - 10:51 AM

Attaboy, 996, I figured it was something like a nights sleep that was keeping you from seeing the light! You can use either > or >>, as noted above: just depends how many log files you want, and how many times you need to "call" it.

Page 1 of 1

## 1 User(s) are reading this topic0 members, 1 guests, 0 anonymous users

All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy