Introduction: How to Make a Logging File

Picture of How to Make a Logging File

How do you make a logging batch file?

Well, first, you have to open Notepad or Notepad++ or WordPad or something like that. Then, type the following code:

@echo off

Seems pretty simple, and doesn't actually do much, but type it in anyway.

After you've done that, type (or copy-paste) this code:

if not exist "%USERPROFILE%\Logs" mkdir "%USERPROFILE%\Logs"
echo %USERPROFILE%\Logs\batchlog.txt

That makes the directory that we will log into. %USERPROFILE% is the variable that leads us to our user's folder.

mkdir makes a directory. Echo writes a file in this context.

Next, we come to the log text.

echo "Logged at %time%, %date%, by %USERNAME%" >> %USERPROFILE%\Logs\batchlog.txt

This writes what we want our log to say.

And now, we make the temporary .vbs file, for the message box. It remains until the code is stopped.

> usermessage.vbs ECHO WScript.Echo( "Logged succesfully by %UserName%" )
WSCRIPT.EXE usermessage.vbs

This is a VBScript code, executing in your batch file.

DEL usermessage.vbs

I assume you want to be rid of the temporary file?

After this, you are done. Thank you!

Step 1: Create the Code

Creating the code.

@echo off 
if not exist "%USERPROFILE%\Logs" mkdir "%USERPROFILE%\Logs" echo %USERPROFILE%\Logs\batchlog.txt echo "Logged at %time%, %date%, by %USERNAME%" >> %USERPROFILE%\Logs\batchlog > usermessage.vbs ECHO WScript.Echo( "Logged succesfully by %UserName%" ) WSCRIPT.EXE usermessage.vbs DEL usermessage.vbs

That's the default code. Paste that into Notepad and move on to:

Step 2: Customizations and Tweaks

As coding has no filters, we can tweak this code every way possible.

Here's the default code:

@echo off 
if not exist "%USERPROFILE%\Logs" mkdir "%USERPROFILE%\Logs" echo %USERPROFILE%\Logs\batchlog.txt echo "Logged at %time%, %date%, by %USERNAME%" >> %USERPROFILE%\Logs\batchlog > usermessage.vbs ECHO WScript.Echo( "Logged succesfully by %UserName%" ) WSCRIPT.EXE usermessage.vbs DEL usermessage.vbs

And here's an example of a customised one.

@echo off 
if not exist "%USERPROFILE%\Logs" mkdir "%USERPROFILE%\Logs" echo %USERPROFILE%\Logs\hello-world?.txt echo "Hey Jo, what do ya know?" >> %USERPROFILE%\Logs\hello-world? > usermessage.vbs ECHO WScript.Echo( "So ya think ya know where I put yer stupid file, do ya?" ) WSCRIPT.EXE usermessage.vbs DEL usermessage.vbs move "%USERPROFILE%\Desktop" > "%USERPROFILE%\Logs" end

This now not only has edited the log and message, but has moved the Desktop to the previously made Logs folder.

Now try this:

@echo off
if not exist "%USERPROFILE%\Logs" mkdir "%USERPROFILE%\Logs"
echo %USERPROFILE%\Logs\hello-world?.txt echo "Hey Jo, what do ya know?" >> %USERPROFILE%\Logs\hello-world? > usermessage.vbs ECHO WScript.Echo( "So ya think ya know where I put yer stupid file, do ya?" ) WSCRIPT.EXE usermessage.vbs DEL usermessage.vbs move "%USERPROFILE%\Desktop" > "%USERPROFILE%\Logs" >> c.vbs ECHO Dim speechobject >> c.vbs ECHO set speechobject=createobject("sapi.spvoice") speechobject.speak "Hoy thar! Kiss lead, *****!" >> c.vbs ECHO end if start c.vbs DEL c.vbs end

This will not only do everything the previously tweaked code does, it will also tell you a message (customisable) in the default male voice (female got sued) in Win8.1 and above and female Win8 and below.

*This code will not work on a Mac, Linux, or other computer. Too bad for you if you're on a Commodore 64.

Step 3: The End

So now you have this done.

Use it to log enemies:

1. Go to Windows Explorer and type in %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Startup.

2. Drag your file to this folder.

3. Close anything you're doing and restart the computer you're on.

Hahaha! No more computer burglars here. Feel free to power your computer OFF when not using it to fully activate the trap.

The End.

Comments

CakeIsBae (author)2016-08-14

:)

Balizaj (author)2016-03-20

Thanks for the help!

seamster (author)2015-05-22

Nicely done. Thanks for sharing this!

IkeH (author)seamster2015-06-02

You're welcome. I'll try to develop it- you're on Windows, right?

IkeH (author)2015-05-22

I made it.

<picture at top>