Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Make a .bat save everything in the window to a .txt?  (Read 3546 times)

0 Members and 1 Guest are viewing this topic.

Salthas

  • Guest
Make a .bat save everything in the window to a .txt?
« on: December 10, 2007, 12:26:01 PM »
Well, I have made a .bat file that gives you options.

The problem is that I cant figure out how to save everything the program writes to a txt.
I already have it saving the time and renaming the file and such, as far as ive understood it should be after the .exe in the code.

Code: [Select]
ECHO @prompt set date=$d$_set time=$t$h$h$h > {a}.bat
%comspec% /e:2048 /c {a}.bat > {b}.bat
FOR %%v in ({b}.bat del) do call %%v {?}.bat
ECHO %date% %time% >> logonserverlog.txt
ECHO Logging logonserver
START /B /WAIT logonserver.exe
ECHO @prompt set date=$d$_set time=$t$h$h$h > {a}.bat
%comspec% /e:2048 /c {a}.bat > {b}.bat
FOR %%v in ({b}.bat del) do call %%v {?}.bat
ECHO %date% %time% >> logonserverlog.txt
FOR /F "tokens=1-5 delims=:" %%d in ("%time%") DO rename "logonserverlog.txt" %%d-%%e.txt
GOTO START

This is part of the code. What this is going to do (you probably understand just by looking) is make a file called logonserverlog.txt, save the date, and time and then whenever it shuts down or crashes (most likely crashes) then it will save the time there as well. It also renames the file to the time it stopped.

I also have an option of making it loop the start, so it automatically starts when it crashes.
Guessing that the command for exporting the text to the .txt has to be after the START.
Every comment is welcome.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Make a .bat save everything in the window to a .txt?
« Reply #1 on: December 10, 2007, 04:39:10 PM »
Wow! I haven't seen a date/time extraction routine like yours since DOS days. But hey, if it worked then, it should work now.  ;D

Have you tried simply redirecting the output of logonserver.exe to your log file?

Code: [Select]
START /B /WAIT logonserver.exe >> logonserverlog.txt

If you don't need all the output in your log file, you might be able to split out the STDOUT and the STDERROR data streams.

Just a thought. 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

Salthas

  • Guest
Re: Make a .bat save everything in the window to a .txt?
« Reply #2 on: December 11, 2007, 10:42:51 AM »
using
Code: [Select]
START /B /WAIT logonserver.exe >>logonserverlog.txt was the first thing I tried. However that caused everything to stop and not work.

However, after some messing around I managed to get it working.

Code: [Select]
START /B /WAIT logonserver.exe>logonserverlog.txt
that almost made me cry thinking of all the time spent figuring that out.
But thanks alot for your response ^_^ might pick up php or autoit again :)