Wednesday, October 26, 2005

VMware Player

VMware Player is free software that enables PC users to easily run any virtual machine on a Windows or Linux PC. VMware Player runs virtual machines created by VMware Workstation, GSX Server or ESX Server and also supports Microsoft virtual PC and Symantec LiveState Recovery disk formats.

For more details see :

Saturday, October 22, 2005

MakeCab : Part 3 - Compress multiple files in multiple folders

By default, MakeCab does not preserve folder path when it compress the files.

Try the following directive file and check the CAB file. You will notice the path information is not in the CAB file. Replace the file list with your actual files.

.Set CabinetNameTemplate=mycab.CAB
.Set Cabinet=on
.Set Compress=on
"folder2\This is a third file.doc"

To preserve the path information, you have to use the DestinationDir directive. Modify the directive file to look like this:

.Set CabinetNameTemplate=mycab.CAB
.Set Cabinet=on
.Set Compress=on
.Set DestinationDir=folder1
.Set DestinationDir=folder2
"folder2\This is a third file.doc"

Run the MakeCab against the directive file and open the CAB file. You should see the path information is preserved.

Thursday, October 20, 2005

MakeCab : Part 2 - Compress multiple files

To compress multiple files into a single CAB file, you need to use a directive file.
The directive file contain instruction how MakeCab should compress and package the files.

Below is a sample of the most basic directive file. Replace the file list with your actual files.

.Set CabinetNameTemplate=mycab.CAB
.Set Cabinet=on
.Set Compress=on
"This is a third file.doc"

All directive start with ".". Comment start with ";".

In the above example,
option explicit specify all variables must be declared before it is used.

CabinetNameTemplate specify the name of the output CAB file.

Cabinet specify whether include the files in the CAB file. When creating setup package, you can use this directive to exclude certain file such as setup.exe from being included into the CAB file.

Compress specify whether to compress the file.

The remaining lines specify the files to be included into the CAB file.

To compress the files using the directive file, run the following command:

makecab /f your_directive_file.ddf

Once completed, the CAB file will be created inside a folder named "disk1". Two more files, setup.inf and setup.rpt is also created. You can just take the CAB file and ignore the others.

Wednesday, October 19, 2005

MakeCab : Part 1 - Compress single file

Makecab is a utility mainly used for packaging setup program and compression.

For the discussion of this blog, I will only focus on compression. Makecab is a handy tool to compress files. Makecab come with Windows XP and Windows Server 2003(not sure about Windows 2000) and both OS recoginze the CAB file and able to extract it without any compression utility installed.

I found this very useful when I work on production server where there is no compression utility like Winzip is installed. For example, there was once I need to copy a database file which is about 250MB to another PC and to my thumb drive. It is a huge file to copy. So I use MakeCab to compress the file before copying it out.

However, Makecab is a command line utility and using it is not that straight forward.

I will walkthrough 3 scenario of using Makecab to compress file.
1) Compress single file.
2) Compress multiple files in the same folder.
3) Compress multiple files in multiple folders.

It is very straight forward to compress a single file. Go to your command line and run the following command:

makecab your_source_file

For example, to compress a readme.doc to, the command is :

makecab readme.doc

Sunday, October 16, 2005

Bad Error Message Hinder Productivity

I was writing an C# Console application which I use System.Web.Mail.SmtpMail to send
email out. System.Web.Mail.SmtpMail internally use CDO for Windows 200 (CDOSys) to
send the mail out.

While my application was running, I got an exception when calling the SmtpMail.Send()
method. The exception message was :

Could not access CDO.Message object.

At first thought, the exception could be due to one of the following reasons:

  • The CDOSys.dll component is not registered properly on the machine.
  • The application does not have enough permission to read the registry and instantiate the component.

So, I went on to search the MSDN for the possible cause and mitigation of error. I found a few KB articles and try the settings suggested in the articles and still not luck. I try a couple more things to try to get it work. After half an hour, still nothing was working.

So I decide to reference the CDOSys.dll using COM interop in my C# project and replace the original code with calls to CDO.Message directly. When I ran the application, the exception message I got was :

Unable to connect to SMTP server

Now, things become helpful.I check my SMTP server setting and found out that I gave the wrong IP. I type in the correct SMTP Server IP, ran the app again and everything work now. I move on to put back my original System.Web.Mail.SmtpMail code with the correct SMTP Server IP and get everything working. This whole process took me only 5 minutes.

If the System.Web.Mail.SmtpMail.Send() throw an exception with more precise message, it would have save me 30 minutes time for looking at the wrong thing.

The lesson here is :
If you does not return a meaningful exception/error message which precisely describe the error, you will drive your user nuts and mislead them into looking at the wrong remedy. This will essentially make your API/application less usable.

Labels: ,