How to enable http compression for a folder in IIS 6.0

By default, when you try to enable compression for a folder in IIS 6.0, you will get the following error message

G:\Inetpub\AdminScripts>cscript adsutil.vbs set w3svc/1/root/sample/DoDynamicCompression true
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

The path requested could not be found.
ErrNumber: -2147024893 (0x80070003)
Error Trying To Get the Object: w3svc/1/root/sample

In order to make it work, you will have to create a key for the folder in the IIS metabase

To create a key, go to the properties of the folder and enable and disable the log visits check box or if its already enabled, disable and enable it again and click on apply and ok. This will create the following key in the metabase.

<IIsWebDirectory Location ="/LM/W3SVC/1/ROOT/sample">
<Custom Name="UNCPassword" ID="3003" Value="49634462500000000600000040000000b948cacfe79500009c1b6d08e34531889ceb6984a2feb9d7d3c8ade09b7ff295b59459ff6d47380aca6382e06e7957c3335a4dd5604625dec0b5d7a350161fa8c9b55089ae494e7a"
Attributes="INHERIT | SECURE"

Once the above key is created for the folder in the metabase, you should be able to enable compression at the folder level by running the following commands from the inetpub\adminscripts folder

1) cscript adsutil.vbs set w3svc/<WebSiteIdentifier>/Root/<FolderName>/DoDynamicCompression true for enabling dynamic compression
2) cscript adsutil.vbs set w3svc/<WebSiteIdentifier>/Root/<FolderName>/DoStaticCompression true for enabling static compression