Creating ZIP archive from a Batch script

While writing a data collection script, I had a requirement to compress some files into a single archive. At first, it did not sound too challenging (Windows has integrated ZIP supported via Send To Compressed (zipped) folder since Windows XP), but it seems it is not so easy if you throw few extra requirements for this task:

After reading some Microsoft documentation, many online forums and trying many differing things, I finally came up with the solution. Continue reading

Count number of users who logged on to workstation in the last month (with Batch script)

Recently, at my job, I had a task to write script/program to count how many users had logged to workstation in the last month. While my colleague tried to complete this task with C#, I’ve decided to use old good Batch. In fact, I was thinking about using PowerShell at first, but since all computers this script will be run in are running Windows XP and do not have PowerShell installed.

To accomplish what I want I’ve found out about VBS script called EVENTQUERY which exists in Windows XP. After reading documentation I’ve decided that it would allow me to do exactly what I need. Though the script that relies on EVENTQUERY.VBS file, it wouldn’t work on newer Windows OS (Vista, Windows XP), but it wouldn’t cause any problems since, as I’ve mentioned before, all computers this script will be deployed to runs on Windows XP. If I would need it to work on Windows 7 later, I’m probably gonna use PsLogList from SysInternals. Continue reading