Dogway

Batch to Log & Console

21 posts in this topic

My laptop crashed a month ago.

I'm back again and now I tried with a more on earth situation, using simple commands.

I created a test rar: link

basically this is the content:

TEE.bat in the folder

Run.bat

prueba.cmd  ^|  TEE.BAT  [ -a ]  >mylog.txt

prueba.cmd

xcopy /Y "Banco\Copiar.txt" "Banco/Folder"
ping localhost -n 5 >nul

ECHO.
ECHO Removing installations logs and other interesting crap
ECHO Please wait...
DEL "Banco\Borrar.txt"
rd /s /q "Banco/Folder"

I hit run and it processes everything fine and exports to log, but I don't see anything in console. Do I need tail.exe or something? If I use the TEE.VBS variant I get the output on screen and log at the same time, but only the command answers, not the questions as tee.bat does)

EDIT: OK, I solved it! Finally I used the TEE.VBS variant. In order to make it output command calls as well I had to remove the @ signs, and now I have full log on console screen and log at the same time. If someone still wants to help with the Tee.bat method I'd be welcome, for the sake of learning.

Edited by Dogway
0

Share this post


Link to post
Share on other sites
prueba.cmd

xcopy /Y "Banco\Copiar.txt" "Banco/Folder"
ping localhost -n 5 >nul

ECHO.
ECHO Removing installations logs and other interesting crap
ECHO Please wait...
DEL "Banco\Borrar.txt"
rd /s /q "Banco/Folder"

Thanks for using the method I provided which uses built-in tools and requires no third party utilities. I will add that I see little point in using a batch file which calls a batch file which calls a utility over one which simply calls a vbscript..

One question, have you deliberately removed a section of your script?

If not, you're performing tasks for no reason, there is no point in copying a file to a directory then removing that directory

0

Share this post


Link to post
Share on other sites

Yes, Yzöwl, there's no point, it's just a staged test (dummy) example to test things out. On the real script I will be installing programs and patches.

Thanks for all the help!

0

Share this post


Link to post
Share on other sites

Can you log registry changes this way?

0

Share this post


Link to post
Share on other sites

I must say that it still isn't perfect at all. It gives me almost the full thing, but fails and errors aren't passed to the log, probably because as commented above they are passed through the error channel, making my original purpose meaningless, since all I wanted with this is to check errors after all. Anyways, I'm not concerned anymore so if anyone want to help, then it's welcomed.

0

Share this post


Link to post
Share on other sites

If you are installing software/applications you cannot expect that each developers installer will have built in an error logging procedure which can be output through a command line interface.

For instance, Windows Installer uses the /L switch for logging to a file.

In some cases, you may be better advised outputting all to a log file then displaying that output to the console.

Also if it is only the error stream you are interested in have you tried changing the tee.vbs to read:

set con = createobject("scripting.filesystemobject").opentextfile("con:", 2)
do until wsh.stdin.atendofstream
s = wsh.stdin.readline
wsh.stderr.writeline s : con.writeline s
loop

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.