Category Archives: System Administration

A post about system administration

Python 101: Writing a cleanup script

Editor’s note: This is a guest post from Yasoob Khalid who authors the Free Python Tips blog

So hi there guys! I hope you are fine. So what is in this post? Today we will be writing a cleanup script. The idea for this post came from Mike Driscoll who recently wrote a very useful post about writing a cleanup script in python. So how is my post different from his post? Continue reading Python 101: Writing a cleanup script

Python: Changing Microsoft Office User Initials

A couple of months ago at work, we received a report that a file was locked. The dialog that appeared showed the initials of a user who wasn’t even working for us any more. Thus we discovered an annoying bug that can crop up with Office. Basically, a user is asked by Word or Excel to input their name and initials during the first run of that respective application and it will keep that data no matter who logs into the machine later on. This can lead to some serious confusion when we get error messages of this sort. Anyway, let’s take a quick look at how to get this done. Continue reading Python: Changing Microsoft Office User Initials

How to Find and List All Running Processes with Python

The other day, I was tasked with finding a way to get a list of all running processes on a Windows XP virtual machine. I was also supposed to include information about how much CPU and memory each process used. Fortunately, this didn’t have to be a remote script, but one that could be run on the client. After a fair bit of Googling here and there, I finally found a solution. In this article, we’ll look at some of the rejects as well as the eventual solution, which happens to work cross-platform. Continue reading How to Find and List All Running Processes with Python

Getting Remote Drive Space on Windows

After about a year or so at my current job, as we were still working on upgrading the last few Windows 98 machines to Windows XP, we had a need to check which machines on our network were getting low on disk space. The issue was cropping up because we had Windows XP loaded on several machines that had 10 GB hard drives and a few with 20 GB and one or two with just 4 GB. Anyway, after some digging online, I discovered that the PyWin32 package could accomplish what I needed. Continue reading Getting Remote Drive Space on Windows

PyWin32: Getting Windows Event Logs

The other day, there was a post on one of the mailing lists that I follow about accessing the Windows Event Logs. I thought that was an interesting topic, so I went looking for examples and found a pretty nice example on ActiveState. In this article, you’ll find out what I discovered. Continue reading PyWin32: Getting Windows Event Logs

Python: Running Ping, Traceroute and More

Last year I needed to figure out a way to get the following information with Python: get the route table, capture the data from pinging a series of IPs, run tracert and get information about the NIC(s) installed. This all needed to be done on a Windows machine as it was part of a diagnostics script to try to figure out why the machine (usually a laptop) wouldn’t connect to our VPN. I ended up creating a wxPython GUI to make it easy for the user to run, but these scripts will work just fine without wx. Let’s see what they look like! Continue reading Python: Running Ping, Traceroute and More

How to Send Email with Python

Where I work, we run a number of login scripts written in Python. When an error occurs in one of those scripts, we want to know. So we wrote a simple Python script to email the error to us. Since then, I’ve needed to figure out a way to send attachments with some of my more advanced scripts. If you’re a long-time reader of this blog, then you may remember wxPyMail, which was a simple wxPython program that could send email. In this article, you’ll discover how to send email with just Python’s standard library. We will focus on smtplib and the email modules. Continue reading How to Send Email with Python

Restarting PCs with Python

Have you ever wanted to restart your Windows PC with out pressing Start, Shutdown or CTRL+ALT+DEL? What about restarting your annoying co-worker’s PC…the one who just doesn’t know when to shut up? Well, Python has the answer and this blog will tell you how to do it! Continue reading Restarting PCs with Python

Python’s _winreg: Editing the Windows Registry

Python’s standard library is known for including lots of handy modules and packages that can be used without installing anything else. That’s one of the primary reasons that its standard library is called “batteries included” so often. So it should come as no surprise that Python includes a Windows only module for editing the Windows Registry. This particular module goes by the odd name of _winreg (odd because it starts with an underscore). In this article, we’ll learn the basics of working with the Registry using this “battery”. Continue reading Python’s _winreg: Editing the Windows Registry

Finding Installed Software using Python

Have you ever wondered what software was installed on your PC? Most people who use Windows would probably go to Add/Remove Programs to find out this information, but they’re not programmers. No, programmers have to script it because it’s just in our blood to do so. I actually had another reason to do so: my boss wanted me to log what was installed on our user’s PCs so we’d know if our users were installing unauthorized software. Thus, there’s also a practical reason to attempt this. Continue reading Finding Installed Software using Python