By Amitesh Singh
This is really great to make the log files. You should have some knowledge of dos commands (including batch file programming, redirection and pipeline tricks).
MAKING LOG FILES OF TXT
LAUNCHING LOG FILES
First open a txt file or edit a file in dos by using edit command and save as "file_name.bat".
I will show you:
C:\>edit txtlog.bat
CODING OF LOGGING BATCH FILE
The coding of the actual batch file that will log the user's activities is quiet simple.
A simple example:
@echo off
echo TXT FILE>>c:\mylogfiles\usertxtlog.txt
echo %1>>c:\mylogfiles\usertxtlog.txt /*send the file name of the file opened to the log file,c:\mylogfiles\usertxtlog.txt*/
notepad %1 /*launch notepad so that user does not know some thing going wrong*/
exit
Well you can add date and time command in the batch file, but one problem is that you need to press enter too, which in turn has to be entered in the batch file too(try this and see what happen).
@echo off
echo TXT FILE>>c:\mybatchfiles\amitesh.txt
time>>c:\mybatchfiles\amitesh.txt
echo FILE NAME: %1>>c:\mybatchfiles\amitesh.txt
date>>c:\mybatchfiles\amitesh.txt
time>>c:\mybatchfiles\amitesh.txt
notepad %1
exit
As you are the system administrator so this can give some clue to the user that some thing is wrong in my computer. You can also remove this fault by using pipeline tricks which I am now going to discuss.
DATE and TIME are basically designed to interactively set the computer's record of today's date and current time, but if we only want to use this commands only to show the current date and time.
We can use redirection of input to hand the enter key to the date and time program. First, we create an empty batch file (let name is empty.bat in C: directory) which is equivalent of the enter key pressed by itself.
Then we dos a command in this manner:
c:\>time<empty.bat
Now we can make the above batch file smarter in this way:
TXTLOG.BAT
@echo off
echo TXT FILE>>c:\mybatchfiles\amitesh.txt
echo FILE NAME: %1>>c:\mybatchfiles\amitesh.txt
date<c:\empty.bat>>c:\mybatchfiles\amitesh.txt
time<c:\empty.bat>>c:\mybatchfiles\amitesh.txt
notepad %1
exit
Now locate any text file, select it (at once) and press the SHIFT key. Keeping the SHIFT key pressed, right click on the txt file to bring up the OPEN WITH.... option. Click on the OPEN WITH... option and choose OTHER button and locate the batch file program which contains the logging code and selecting the icon "always use this program to open this type of files. Now click OPEN and OK.
I include exit command at the end of program to "MAKE THE LOGGING BATCH FILE TO ESCAPE FROM THE USER'S EYES".
When any TXT file will open there will be log entry in the file named amitesh.txt.
You can attach this batch file to other types of files like *.dat,*.html,*.ps..etc.
NOTE :Using the above tricks you can easily change the files on which you want to keep an eye.
CREATING LOGFILE IN WORDPAD
If you want to make log files in WordPad document then in the TXTLOG.BAT instead of writing "notepad %1", write "write %1".
.
HOW TO MAKE LOG FILES ON THE NET (only for Windows XP)
If you have some knowledge of TELNET service then you can make log files of each server connection.
First go to dos prompt.
Type 'telnet' & press enter.
Now type set?
Set log file c:\lognotes.txt.
This txt file will store all the works you have done on the net.
You can make a batch file program which makes log files without going to type log files each time.
Examples:
TEL.BAT
@echo off
telnet
set logfile c:\log.txt
open %1 %2
HOW YOU RUN IT
C:\>TEL.BAT pop.mail.yahoo.com 110
ADTELNET.BAT
@echo off
echo Welcome to the 'TELNET' service
echo type of server(ports)
start
echo 1:TELNET(23)
echo 2:FTP(21)
echo 3:SMTP(25)
echo 4:POP(110)
echo 5:HTTP(80)
echo 6:EXIT
choice "choose the service"/c:123456 /n
if errorlevel 6 goto end
if errorlevel 5 start c:\telnet %1 80
if errorlevel 4 start c:\telnet %1 110
if errorlevel 3 start c:\telnet %1 25
if errorlevel 2 start c:\telnet %1 21
if errorlevel 1 start c:\telnet %1 23
:end
HOW YOU RUN IT
C:\>adtelnet.bat hotpop.com
AUTHOR Amitesh Singh
ISM
DHANBAD
More Articles by Amitesh Singh
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.
Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.
We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.
Click here to add your comments
---September 28, 2004
Wed Aug 12 09:43:23 2009: anonymous
How to create a log file when multiple files in one directory are accessed, installed, copy etc
For example: C:\applications contains following files.
app1.exe
app2.exe
app3.exe
app4.exe
app5.exe
Assume app1.exe is selected for installation.
app2.exe is selected for copy.
log.txt should look like this:
Date Time app name operation
12-08-2009 23:00 app1.exe installation
12-08-2009 23:12 app2.exe copy
Wed Aug 12 10:09:07 2009: TonyLawrence
app1.exe > yourlog
app2.exe >> yourlog
app3.exe >> yourlog
Wed Aug 12 10:28:38 2009: anonymous
i m a beginner
i need to know about the process of creating log file for the above mentioned task
Wed Aug 12 10:36:36 2009: TonyLawrence
And that's what I told you. Use a single ">" for app1, use ">>" for app2 and "yourlogfile" will contain what you want.
Wed Aug 12 17:02:38 2009: anonymous
I dont know about programming in Windows
can you let me know how to create a log file and then include all the details as mentioned
Thu Aug 13 12:42:33 2009: TonyLawrence
I did exactly that. You need to create a .bat file containing the things you want to run with redirection as I explained.
Thu Aug 13 15:57:47 2009: anonymous
I did what you asked me to do, but the log file created contained no information. It was a blank file
Thu Aug 13 16:04:06 2009: TonyLawrence
Then your applications are not writing to STDOUT.
That's often a problem with Windows programs: Windows programmers tend to be clueless, so simple things become difficult.
You really should go to a Windows site to get more help. We don't like Windows or Microsoft much here.
Wed May 18 06:49:57 2011: gmav
you can use the command
time /t
this gives you the time without the need to press enter after that
Don't miss responses! Subscribe to Comments by RSS or by Email
Click here to add your comments
If you want a picture to show with your comment, go get a Gravatar