Skip to content


Send A File Path from the Windows Context Menu to App

Here’s an easy way to pass the file path to a console app. I needed a way to right click on a folder or a file, and send the path to a console app, where the app does its thing with the file(s).

To show you what I mean:

When I right-click on “coolbeans” it runs the following console app, which simply displays the path:

The C# app is pretty straightforward. Basically, once you have the file path, you can apply any operations on the file.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace dan_rocks
  class Program
    static void Main(string[] args)

So there’s nothing crazy going on in the above sample. You basically just have to add a few entries to the Registry.

If you want to pass a folder path when you right-click on it, and select the option in the context menu, create a new entry:


If you want to pass in a file, do the following:


Let’s pass in the filepath to note.exe:

Do that and you’ll see the following:

Compress and Move Log Files

Sometimes log files bog a system down. For one of our servers, I made this little Python script that compresses (via WinRAR) the log files in a directory, and then moves them to a backup location. The only little catch is that I wanted to leave the latest log files for in that directory. Log files are created daily, so the the latest log files have a datestamp of today. Here’s how I did it.

First Create the Python Script:

import os
import datetime

dateStamp  ="%Y-%m-%d") 
imsLogPath = 'd:\\LogFiles\\'                     
# Don't use a mapped drive but use UNC for network drives. Task Schedule seems to choke when it calls Python.
newRARPath = '"\\\\\\Root\\backups\\' + dateStamp + '.rar"'
rarPath    = '"C:\\Program Files\\WinRAR\\rar.exe" a -m5 ' + newRARPath 

# Get Latest Files
smtpLatest   = os.popen(r"dir /od /a-d /b " + imsLogPath + "SMTP*.log").read().splitlines()[-1]
postLatest   = os.popen(r"dir /od /a-d /b " + imsLogPath + "POST*.log").read().splitlines()[-1]
ischedLatest = os.popen(r"dir /od /a-d /b " + imsLogPath + "iSched*.log").read().splitlines()[-1]
relayLatest  = os.popen(r"dir /od /a-d /b " + imsLogPath + "Relay*.log").read().splitlines()[-1]
qengLatest   = os.popen(r"dir /od /a-d /b " + imsLogPath + "Qeng*.log").read().splitlines()[-1]

# Get List of All Files
allFiles     = os.popen(r"dir /od /a-d /b " + imsLogPath + "*.log").read().splitlines()

# Remove Latest Files from All Files List
allFiles.remove( smtpLatest )
allFiles.remove( postLatest )
allFiles.remove( ischedLatest )
allFiles.remove( relayLatest )
allFiles.remove( qengLatest )

# allFiles Array Has the list of files

# Flatten Array allFiles to be used as a parameter in system command
flatLogPathList = ""
for filenameWithPath in allFiles:
  flatLogPathList = flatLogPathList + imsLogPath + filenameWithPath + " "

# Execute WinRar
path = rarPath + " " + flatLogPathList.rstrip()
os.system( '"' + path + '"' )

# Delete all log files
os.system( '"del ' + flatLogPathList.rstrip() + '"' )

Then I set up the Scheduled Task:

With these Settings:

Get Latest File

In my last post, I made a quick script that checks for the date. It was very limiting, since it used the dir command. This one uses several date/time Python modules and is more capable.

import os, os.path, stat, time
from datetime import date, timedelta, datetime

# Reference

def getFileDate( filenamePath ):    
  used = os.stat( filenamePath ).st_mtime      
  year, day, month, hour, minute, second = time.localtime(used)[:6]
  objDateTime = datetime(year, day, month, hour, minute, second)
  return objDateTime
  # Ways to reference this DateTime Object
  # objDateTime.strftime("%Y-%m-%d %I:%M %p")
  # objDateTime.year
  # objDateTime.month

def isDaysOldFromNow( filenamepath, days ):
  # Checks how old a file is. Is it older than "days" [variable] days?
  inTimeRange = False  
  timeDeltaDiff = ( filenamepath ) ).days
  # Check if the file's date is days old or less:
  if ( timeDeltaDiff >= days ):
    inTimeRange = True  
  return inTimeRange

fname = "C:/temp/decision2.pdf"  

# Set this variable to check if the file is this days old
howOld = 3

if ( isDaysOldFromNow( fname, howOld ) ):
  print fname, "is more than", howOld, "days old"
  print fname, "is NOT more than", howOld, "days old"


Base Tag Not Supported In Hotmail

It’s interesting how the <base> works in various clients. I thought all major web clients would support it, but apparently it is not the case.

Let’s look at how some email clients process this tag:! Web Mail

Base tags are modified by their mail server and relative URLs are changed to absolute. So it works.

Gmail Web Mail

Base tags are modified by their mail server and relative URLs are changed to absolute. So it works.

Gmail Account via Thunderbird

Base tags are shown and its functionality is intact. URLs remain relative. So it works.

iMS Account via Outlook 2007

Base tags are shown and its functionality is intact. URLs remain relative. So it works. More info on iMS.

ShinyLight Account via iPhone

Can’t see the HTML, but all URLs worked.


Unfortunately, this is the ugly duckling. Hotmail servers remove the base tag and leave your relative links as relative. Big FAIL.

Console2 Alternative to CMD

You know what, I tried PowerShell and I guess I never got used to it. I’ve been using DOS for the longest time that I prefer its simplicity when navigating through files. As far as scripting with it – forget it – it’s very cryptic and limiting, not to mention awkward. That’s why for scripting now I’m using Python. Nonetheless though, I sometimes need a playing field to run the scripts for, or running console utilities. That’s where Console2 comes in.

Console2 is a great tool that provides tabbing (you can tab through multiple consoles) and several ways to customize the UI. Here’s an example:

I prefer this configuration:

How I Have It Setup

Download Console2:

I have the Console2 open up when I hit CTR+\ via AutoHotkey. Here’s the snippet for this to happen in AutoHotkey. I have this run when Window starts (it must stay in memory).

^\::Run C:\dan-local\dos-win\Console.exe

Change the CMD prompt by creating a PROMPT system variable:

Download the Console2 Config File

Other Tips

Good tip about command console = CTRL+I
can select files in the current directory, kinda like autofill-in
you can also put in parts of the file and it autoputs it for you

Rename tab

New Tab with default transparency

New Tab with lighter transparency

Switch to NEXT adjacent tab

Switch to Previous adjacent tab

Goes to the tab instance. To make it easier, it’s best if you rename your tabs,


So for example,

1.Batch File
2.wget list
3.ftp the files

Search As You Type

Just upgraded recently from WindowsXP to Windows7. One feature I used a lot forever (since Win95 I think), was the search as you type (this is what I call it anyways). It’s when you have an Explorer window open (let’s say in this case c:\ ) and you type “W” – it moves the cursor to directory that starts with the letter “W.” You can type “Win” quickly and it will go to the first directory that starts with those keywords in case you have directories that start with “Win.”

So after I configured the UI settings on Win7 to the way I saw fit, I realized that this feature was gone. It would automatically start searching for text in all files recursively – very annoying. I asked how to turn this feature off in many forums and do what I wanted to do and no one knew.

I finally figured it out. It was a setting that I turned on accidentally. (D’oh!)

Explorer Window -> Organize -> Folder Options -> View Tab -> When typing
into list view -> Select the typed item in the view

That wasn’t checked. I suppose I did it instinctively without thinking. In WindowsXP, the area is used to trigger Advanced File Sharing, and I guess I didn’t realize this in Windows7. Also, I don’t think in XP this is an option you can control because it just works.

Windows7 Options

WindowsXP Options

Reasons I’m Not a Fan of Google Chrome OS

I’m assuming you’ve seen what Chrome OS can do. Just Google “Chrome OS,” because it’s everywhere.

I would give Chrome OS an 8.0 / 10.0 for computer beginners, like the grandmas of the world. It’s gets a 2.0 / 10.0 for techies. Why? Three reasons.

  • Needs too many resources for what it delivers.
  • Cannot run executables, not even virtually/sandboxed.
  • Needs the cloud for storage.

Kind of annoying that I can’t just run it on any old laptop / netbook. System requirements are too demanding for what it promises and it seems it’s needed just to have that 2-4 second boot-up time, which honestly it doesn’t mean much to me. There’s never a time where I’m in such a hurry that I need my computer that fast, because I’m either doing something else, or I just use my phone.

I some people really care about boot-up time? I’d rather wait 10 more seconds and have the ability to run .EXE files and have it run on old PC’s. For a minimalist device, I have my table PC or iPhone already that can do all that stuff, and I don’t have to worry about malware on the iPhone. I don’t think techies have to worry to much about malware since they’re careful about getting them in the first place and have good Anti-viruses.

Lastly, an Internet connection is not ubiquitous yet. I’m on the subway a lot where there’s no WIFI and sometimes I travel to places without an Internet connection. I want to be able to at least read my latest documents without connecting to the cloud.

The OS is still in the works, so I suppose maybe they’ll address some of these features in the future.

Using Winrar from the Command Line

Winrar is a great tool used for compressing files. It also has a command line tool called “rar.exe” to compress files, in case you want to batch it up. Here’s an example of the most common switches I use.

"C:\Program Files\WinRAR\rar.exe" a -m5 -r -ep1 "C:\temp\Work\Upgrades\2010-02-06\111.rar" "C:\temp\Work\Upgrades\2010-02-06\Post-Upgrade\" 

First path is the location of the rar file to create. The second path is either the location of the file(s) or directory to compress.

options used

  -ep1  Exclude base directory from names
  a     Add files to archive
  -r    Recurse subdirectories (will compress entire directories)
  -m5   Set compression level to maximum

You can even assign a password to it using the -p switch

Fast Delete

I needed to delete 30,000 files that took about 60 GB. I know traditionally it takes forever to delete it in Windows. Even using the “del” command in the console, it’s always been slow for me. Enter Robocopy. I never gave it a chance until today. The way it can delete is by syncing directory against an empty one which was just what I needed. It was able to do it in about 50 seconds. Awesome.

You’ll have to download Robocopy as part of the Windows Server 2003 Resource Kit Tools.

What I used to delete this big directory:

robocopy /MIR c:\empty-directory c:\my-files-to-delete

Testing Database Import Scripts with Snapshots

Can’t stress enough how handy database snapshots (compatible only in Enterprise and Developer editions of SQL Server 2005+) come in when testing bulk imports, data scrubbing, or any sort of data / schema modification script. In nearly no time, I can create a snapshot (via shortcut snippet), run my script – don’t like the results? My script crapped out the data? I can run an instant undo by recovering from the snapshot, which works pretty fast. If I want to create another snapshot, I usually tend to overwrite the snapshot I created, and then create it again.

It’s so handy that I have a snippet for it:

Anywhoot, here’s how you create a snapshot:

CREATE DATABASE YourDatabase_snap ON         -- Name of new snapshot
  NAME = yourdb_data,                        -- Logical filename of source db you want to snapshot
  FILENAME = 'c:\'  -- Sparse file to create
AS SNAPSHOT OF YourDatabase;                 -- Source db name
USE master;
RESTORE DATABASE YourDatabase                    -- Source db name where the data resided
FROM DATABASE_SNAPSHOT = 'YourDatabase_snap';    -- Snapshot db name

Deleting a snapshot is just like dropping a database.

DROP DATABASE YourDatabase_Snap

Computer Tools for the Power User

Here’s a list several tools I use both at home and work. I usually carry these on my USB keychain for easy access. They’re mostly lightweight, fast, and some don’t even require a installation. These are free and NOT Shareware! They are for Windows/Windows XP.


Used for file comparisons. You can compare text files and see, line by line where these files are different.

Great editor for HTML. This integrates nicely into Internet Explorer to “view source.” It can collapse HTML tags.

Microsoft Notepad on steroids. It uses color coding for files of various extensions. Uses transparency so that you can see through the editor window what’s behind it.

Agent Ransack
Search for text in files. The results show you the file and what line your keyword search is in.

Password Manager
It saves your passwords. You can create categories for what kind of passwords they are. Once you save it, you hit CTRL+U to save the user name, and CTRL+C to save the password to the clipboard. It uses a secure 448 bit Blowfish algorithm to ensure the data are not crackable. The password used for securing access to stored data is not saved anywhere.

JR Screen Ruler
A visual ruler you can use to measure pixels on the screen.

Record whatever you do at your Windows Desktop, and can replay them exactly. This is great to record tasks and save them for later.

Get a checksum for a file using hashes: crc16, crc32, xsum, md5.

Telnet/SSH Client

Process Explorer
See information about processes: what files or directories they have open. Kill processes, etc.

Know exactly what’s running when you start windows and turn those annoying programs off.

Simple File Schredder
Simple File Shredder is a utility that securely deletes your files so they can’t be restored.

Restore Deleted Files
This restores files that have been deleted. Use this as a last line of defense. The great thing about this program is that it does not require to install – unlike other applications, where you need to install first.

Angry IP Scanner
Angry IP scanner is a very fast IP scanner and port scanner. It can scan IP addresses in any range as well as any their ports. Its binary file size is very small compared to other IP or port scanners.

Change the date stamp for any file you want.

Great popup blocker.

Good firewall software.

System Spec
System Information Utility. Get a report for practically everything you wanted to know about your computer.

Synchronize files from different folders. I use this to synchronize files from my computer and USB keychain and USB drive. Lots of features.

Microsoft PowerToys for Windows XP
PowerToys add fun and functionality to the Windows experience. What are they? PowerToys are additional programs that developers work on after a product has been released. These tools include: Synchronize file tool, Image resizer to resize a batch of files, power calculator, multiple desktops, tweak UI settings, and more productivity tools.

Windows Internet Browser Plugins

Web Developer Plugin for Firefox
Provides a variety of tools for quickly creating, understanding, and troubleshooting Web pages. This feature is added to the menu when you right click on a page.

Internet Explorer Developer Toolbar
Provides a variety of tools for quickly creating, understanding, and troubleshooting Web pages. This feature is added to the menu when you right click on a page.

IE Context Menu Toolset
This is a set of tools which extend the right-click context menu of Internet Explorer. By simply installing these tools, your browser will have added functionality which can greatly help in debugging pages, designing sites, diagnosing form problems, tweaking design, etc.

Fiddler is a HTTP Debugging Proxy which logs all HTTP traffic between your computer and the Internet. Fiddler allows you to inspect all HTTP Traffic, set breakpoints, and “fiddle” with incoming or outgoing data. Fiddler is designed to be much simpler than using NetMon or Achilles, and includes a simple but powerful JScript.NET event-based scripting subsystem.

Command Console Tools

Like the dir command but displays files/directories with color and in columns.
Way much better! The drawback is if your OS is not using FAT12 or FAT16 type disks, the Bytes Consumed will be wrong.

Great Hexeditor. The only Hexeditor I use.

Get md5 hashes of files or text you type in. Useful if you need to find the md5 hash of a word.

Other Great Sites for Small Tools

These two sites have great little apps for networks, programming, graphics, etc. These are also free.

Systinternals Freeware

Setting Up Ant


Ant (Another Neat Tool) is a tool to automate tasks needed to run successful builds, deployments, and tests. You can run Ant as a stand-alone tool, or run it from Eclipse.

Needed JAR Files

In Ant, a "task" is a single line of instruction that gets run in the build file, as opposed to a "target" which is a group of tasks. There are a core set of tasks in Ant: copy, delete, echo, and many more ( Other important tasks (like FTP/SVN/Mail functionality), however, are not included. For that reason, we need to include these "add-ons" into Ant in the form of JAR files into Ant’s classpath.

The following is a list of additional tasks we need, that are not part of Ant’s core task list (download these before reading on):

Setup to Run Stand-Alone

  1. Install the JRE, if you don’t already have it.
  2. Download latest version of ANT: and unzip to c:\Ant
  3. Download the above latest JAR Files in Zip files. Zip files you download may have more than just JAR files, but you need to isolate these JAR files and put the JAR files into Ant’s classpath, C:\Ant\lib

  4. Put all the JAR files under C:\Ant\lib
  5. Add the following variables to your SYSTEM Variables

    Add this to your existing PATH variable:


    Also, make sure there’s a CLASSPATH and JAVA_HOME system variables setup for the JRE.

    CLASSPATH=.;C:\Program Files\Java\jre1.6.0_07\lib\ext\  
    JAVA_HOME=C:\Program Files\Java\jdk1.6.0_07  

  1. That should be it. Try to run, go to the command console and type "ant". To load a build file, type:
    ant \-buildfile build.ant  

Setup to Run From Eclipse

The typical Eclipse setup already comes with the core Ant tasks, so you just have to get the optional ones. Download the attachment and preferably put them here: C:\Ant\lib

  1. Run Eclipse
  2. Go to Run > External Tools > External Tools Configurations
  3. Double click on the Ant Build Icon
    This will open up the "New_Configuration Wizard"

  4. Name the build DeployStaging (there should already be a name in the field, but it’s called "New_configuration"
  5. Under the Main tab, put in the Buildfile (in this case, "Browse File System…") – browse to where your buildfile is. (No need to include the .properties file, as the build file will call it.)
  6. Under the Classpath tab, click on User Entries then click on "Add External JARs…" and point it to the directory which has all the JARs you downloaded (C:\Ant\lib).
  7. Select all the JARs.
  8. Click Apply.
  9. Click Close.
  10. Save if prompted.
  11. Select the build file and then Go to Run > Run
  12. To Modify the script you’ve just setup, go to Run > External Tools > External Tools Configurations
  13. To select another default target (for example, for to get the latest changes), go to the Targets tab, uncheck the default, and select the target you want (in this case, "update_latest").
  14. Click Apply and close.
  15. To see the build progress in detail, open up the console view by Window > Show View >Other > General > Console.

LogParser to Query IIS logs using SQL

LogParser is a great way to query IIS logs (any text log, actually, that is delimited).

Once you have it installed (default install is to C:\Program Files\Log Parser 2.2), let’s try to query log file ex090915.log from directory C:\WINDOWS\system32\LogFiles\W3SVC1942853941 . The way you would do this, is this:

LogParser "select date, s-ip, cs-method from C:\WINDOWS\system32\LogFiles\W3SVC1942853941\ex090915.log" -rtp:-1

As you can probably imagine, “date”, “s-ip”, and “cs-method” are the column headers from the log file. The select statement goes in quotes. Also, rather naming a table, you give the path to the log file. What’s the argument -rtp:-1 ? If you don’t include this argument, every 10 results, it will prompt you to “press a key…,” then will show you the next batch of results. In any case, the select state we just ran will spit out the following in the console:

date       s-ip            cs-method 
---------- --------------- ---------
2009-09-15 GET
2009-09-15 GET
2009-09-15 GET
2009-09-15 GET
2009-09-15 GET
2009-09-15 GET
2009-09-15 POST
2009-09-15 POST

Elements processed: 27
Elements output:    27
Execution time:     0.02 seconds

LogParser will even generate graphs (.gif format) of your results.

If you want to use a GUI for your queries, I suggest you try Log Parser Lizard.

Log Parser Lizard

Log Parser Lizard is a great free tool if you use Log Parser to parse IIS logs using SQL. It’s a visual tool to query the logs. It also comes with pre-made queries. Let’s take a look at one, “Requests and Full Status by Number of Hits” in IIS logs:

-- Let's query the IIS W3SVC80086301 Log file c:\temp\logs\ex080918.log
SELECT  STRCAT( cs-uri-stem, 
    REPLACE_IF_NOT_NULL(cs-uri-query, STRCAT('?',cs-uri-query))
    ) AS Request, 
  STRCAT( TO_STRING(sc-status),     
    STRCAT( '.',
      COALESCE(TO_STRING(sc-substatus), '?' )
    ) AS Status, 
  COUNT(*) AS Total 
FROM c:\temp\logs\ex080918.log 
WHERE (sc-status >= 400) 
GROUP BY Request, Status 

Which gives you the following result (depending, of course, what’s in your logs):


Also, I could’ve queried all the log files put together, such as:

select * from c:\temp\logs\*log

Also, you can create global variables and use them in your queries so that you don’t always have to put the full path to a file. For example:


I’m setting the variable IISW3C equal to c:\temp\logs\ex*.log . The queries that come with this tool use these variables (keys) as a shortcut. For your IIS logs dir, you may want to set it up to point to C:\WINDOWS\system32\LogFiles\W3SVC80086301 . Once you’ve done this, you can do (HIT F5 to run query):

-- Get the top 10 from all IIS logs
select top 10 * from #IISW3C# 

You can also view LogParser graphs from this tool. Let’s try the query to show all extension with total hits:

  COUNT(*) AS [Total Hits]
GROUP BY Extension 
-- Ignore .CFM extension
ORDER BY [Total Hits] DESC


Running a 32bit or 64bit CPU?

Sometimes Windows alone might not be able to tell you what your machine has. To be absolutely sure, if you at least know you have an Intel CPU, try their Processor Identification Utility.


You can also save a text file report summary of your machine. Here’s my machine at work:

Intel(R) Processor Identification Utility
Version: 4.21.20091215
Time Stamp: 2010/01/27 19:53:40
Operating System: 6.1-7600-
Number of processors in system: 1
Current processor: #1
Active cores per processor: 2
Disabled cores per processor: 0
Processor Name: Intel(R) Pentium(R) D CPU 830   3.00GHz
Type: 0
Family: F
Model: 4
Stepping: 4
Revision: 6
Maximum CPUID Level: 5
L1 Instruction Cache: 2 x 12 Kµops
L1 Data Cache: 2 x 16 KB
L2 Cache: 2 x 1 MB
Packaging: LGA775
Platform Compatibility Guide: 05B
Enhanced Intel SpeedStep(R) Technology: Yes
MMX(TM): Yes
Intel(R) SSE: Yes
Intel(R) SSE2: Yes
Intel(R) SSE3: Yes
Intel(R) SSE4: No
Enhanced Halt State: Yes
Execute Disable Bit: Yes
Intel(R) Hyper-Threading Technology: No
Intel(R) 64 Architecture: Yes
Intel(R) Virtualization Technology: No
Expected Processor Frequency: 3.0 GHz
Reported Processor Frequency: 3.0 GHz
Expected System Bus Frequency: 800 MHz
Reported System Bus Frequency: 800 MHz

FYI, this is from Intel:

Certain advanced Intel(R) processor technologies require system support features be present to be fully enabled. Please see the notifications below for system features required to enable the listed technologies.

Intel(R) Hyper-Threading Technology
Intel(R) Hyper-Threading Technology requires a computer system with a processor supporting Intel(R) HT Technology and an Intel(R) HT Technology-enabled chipset, BIOS and operating system. Performance will vary depending on the specific hardware and software you use. For more information including details on which processors support Intel(R) HT Technology, see

To verify your system for Intel(R) Hyper-Threading Technology, download the Intel(R) Hyper-Threading Technology Test Utility from

Intel(R) 64 Architecture
64-bit computing on Intel architecture requires a computer system with a processor, chipset, BIOS, operating system, device drivers and applications enabled for Intel(R) 64 architecture. Performance will vary depending on your hardware and software configurations. Consult with your system vendor for more information.

Intel(R) Virtualization Technology
Intel(R) Virtualization Technology requires a computer system with a processor, chipset, BIOS, enabling software and/or operating system, device drivers and applications designed for this feature. Performance will vary depending on your configuration. Contact your vendor for more information.

Intel, Intel Atom, Intel Core, Pentium, Xeon, Celeron, OverDrive, SpeedStep and MMX are trademarks of Intel Corporation in the United States and other countries. Copyright(C) 2010, Intel Corporation. All rights reserved.