DEV Community

Cover image for My First Attempt at Writing a Windows Process Logger in Batch (Yes, It’s Ugly, but It Works)
Mohammad Shams
Mohammad Shams

Posted on

My First Attempt at Writing a Windows Process Logger in Batch (Yes, It’s Ugly, but It Works)

Hey folks 👋

As promised in my first post, I’m learning cybersecurity by building small, real-world tools — even if they’re weird, ugly, or incomplete.

This time I decided to tackle something basic but useful: logging running processes in Windows usng a plain old .bat script. Why Batch? Because I wanted to start from zero, from the most available thing on any machine.


🎯 The Goal

Create a script that:

  • Lists all active processes
  • Logs them into a .txt file with a timestamp
  • Appends, not replaces, data (to monitor changes over time)

⚙️ The Code (bare bones version)

@echo off
set "logfile=process_log.txt"
echo ---- %date% %time% ---- >> %logfile%
tasklist >> %logfile%
echo. >> %logfile%
Enter fullscreen mode Exit fullscreen mode

Yep. That’s it.

It took me a lot more time than I’m willing to admit to understand how >> really works vs >, but hey — that’s part of the learning curve. 😅
🤔 Why This Matters (for me at least)

In Android or backend work, you usually have libraries or services doing this kind of monetoring. But in cybersecurity, you’re often the one building the tool from scratch — even if it’s just to test a theory.

This script helped me understand:

Basic I/O in CMD

How malware might hide or fake processes

Why log integrity is such a huge deal
Enter fullscreen mode Exit fullscreen mode

I even manually killed and restarted some processes just to see how things change across logs — nothing fancy, but it gave me ideas.
📌 Next Steps

Here’s what I’m planning to add next:

Filter out system processes

Log new processes only (maybe with PowerShell?)

Send alerts (even if just a beep for now 😄)
Enter fullscreen mode Exit fullscreen mode

🧪 What I Learned

Even small scripts can teach you a lot

Debugging in CMD is... a unique experience 😅

I should’ve learned about findstr sooner
Enter fullscreen mode Exit fullscreen mode

🙌 Final Thoughts

If you’re also learning cybersecurity from scratch, don’t be afraid to build basic stuff. Forget funcy UIs or frameworks — just solve a tiny problem and move on.

I’ll keep sharing small tools like this as I go, and I’d love to hear what kind of beginner-friendly ideas you’ve tried too.

Thanks for reading,
Mohammad 🧠

Top comments (1)

Collapse
 
devops_fundamental profile image
DevOps Fundamental

Insightful and well-written as always!