Home > Windows Server Tips > Windows Server Monitoring and Management > Exploring the Windows Server 2003 Resource Kit: Compress.exe and Expand.exe
Windows Server Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

WINDOWS SERVER MONITORING AND MANAGEMENT

Exploring the Windows Server 2003 Resource Kit: Compress.exe and Expand.exe


Tim Fenner, Contributor
10.31.2007
Rating: --- (out of 5)


Expert advice on Windows-based systems and hardware
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


This segment of my review of the tools in the Microsoft Windows Server 2003 Resource Kit dives into the Compress.exe and Expand.exe utilities.

If you need to make a compressed copy of a file via a script or command line, then these utilities may help.

Per Microsoft:

  • The compress utility is a command-line tool that allows you to create compressed copies of files.
  • The expand utility is a command-line tool that allows you to expand compressed files created by the compress utility.

The copy portion is the key to this compress utility. Most simple compression tools will allow you to compress the original file. Compress actually leaves the original target uncompressed, and instead makes a copy of that original and compresses it. It's important to note that this utility does not compress many files into a single file, such as a CAB file. If you choose to compress all the files in a directory (using a wildcard), it creates a single compressed file for each file in the source directory.

After compressing these files, you then use the Expand.exe utility to uncompress the data. You can also use Expand.exe to extract files from a cabinet (.cab).

Requirements:

  • Windows 2000, Windows XP Professional, or Windows Server 2003 operating systems
  • NTFS formatted volume
  • Proper permissions on directory and files you wish to target

Installation:

  • Install the Resource Kit

General use:
Compress Source Destination

Example:

C:\folder1> Compress text.txt c:\folder2 –r

The above example will copy a file in the folder1 directory named text.txt, and create a compressed version of that file in the folder2 directory. The compressed file will be named: text.tx_

Parameters:

  • /r -- Renames expanded files. Compressed files are renamed with the last character in the file name extension set to an underscore ("_") character. The underscore identifies the file as a compressed file.
  • /d -- Specifies that only out of date files within Destination are updated.
  • /zx -- Specifies Lempel-Ziv (LZX) compression. The LZX compression can reduce the package size by up to 18% and increase the self-extracting speed by approximately 50%.
  • /z -- Specifies MS-ZIP compression. This compression is also known as the .cab file format. It is based on the Lempel-Ziv data-compression algorithm.
  • /zq[n] -- Specifies quantum compression. Valid values for n are in the range 1 to 7 (1 yields the fastest speed while 7 gives best compression). The default value for n is 4.
  • Source -- Specifies the source file. The * and ? wildcard characters can be used.
  • Destination -- Specifies the destination file or path, and the destination can be a directory. If Source specifies multiple files and /r is not specified, then Destination must be a directory. If the destination listed on the command line does not include a new file name for the compressed file, the file's original name is used (a new name is required to save the compressed file in the same folder as the original).

Expand Source Destination

Example:

C:\folder2> Expand text.tx_ c:\folder1\text.txt

The above example will expand a file in the folder2 directory named text.tx_ and create an uncompressed version of that file in the folder1 directory. The compressed file will be named: text.txt

Parameters:

  • -r -- Renames expanded files.
  • Source -- Specifies the files to expand. Source can consist of a drive letter and colon, a directory name, a file name or a combination of these. You can use wildcards (that is, * or ?).
  • Destination -- Specifies where files are to be expanded. If Source consists of multiple files and you do not specify -r, Destination must be a directory. Destination can consist of a drive letter and colon, a directory name, a file name or a combination of these.
  • -d -- Displays a list of files in the source location. Does not expand or extract the files.
  • -f:Files -- Specifies the files in a cabinet (.cab) file that you want to expand. You can use wildcards (that is, * or ?).

Issues:

Microsoft's help file oddly states, "Do not use Compress.exe (compress) to compress files or folders on the NTFS file system formatted files or folders. To compress or decompress NTFS-formatted files or folders, use the Compact command-line tool or set the Compressed attribute of the file or folder in Windows Explorer."
More on Windows Server 2003 Resource Kit:
How to use Windows Server 2003 Resource Kit's Clusterrecovery.exe

Demystifying the Acctinfo.dll tool in the Windows Server 2003 Resource Kit.

A guide to the Microsoft Windows Server 2003 Resource Kit Tools.
However, I don't quite understand this warning. True, the compress utility is old, but it seems to work just fine on an NTFS formatted volume, where the files and folders reside. I do know that you cannot use the built-in NTFS file properties dialog box to uncompress a file that has been compressed using this utility. Perhaps Microsoft wants you to make sure to use the compact tool instead so you can use the NTFS file properties windows to uncompress the file.

Windows XP appears to have a bug in that it cannot pass the source path. In other words, if you want to compress a file in the c:\folder1 directory to another directory called folder2, you cannot run the following command: compress c:\folder1\test.txt c:\folder2. If you do, you will receive an ERROR: Unable to open C:\folder1\test.txt message. The only way around this is to navigate to the directory that contains the source file, and then run the compress command. So, using the example above: c:\folder1> compress test.txt c:\folder2.

The Microsoft Windows Server 2003 Resource Kit tools are a set of tools to help administrators streamline management tasks, such as troubleshooting operating system issues, managing Active Directory®, configuring networking and security features, and automating application deployment.

About the author: Tim Fenner (MCSE, MCSA: Messaging, Network+ and A+) is a senior systems administrator who oversees a Microsoft Windows, Exchange and Office environment. He is also an independent consultant who specializes in the design, implementation and management of Windows networks.

Rate this Tip
To rate tips, you must be a member of SearchWindowsServer.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Windows Server Monitoring and Administration
Moving dynamic disks to a new Windows server
A first look at Storage Explorer for Windows Server 2008
Tips for Windows domain controller optimization
Take control of server clusters with Microsoft's ClusDiag tool
Analyze server history with new tool in Windows 2008
Determining the cause of Windows server hang
Preparing to troubleshoot a hung Windows server
Why do Windows servers hang?
Microsoft tool simplifies Windows server cluster configuration
Exploring the Windows Server 2003 Resource Kit: Clusfileport.dll

Microsoft Windows Server 2003 Administration
How to install Windows Server 2003 patches when offline
Validating Windows server clusters with ClusPrep
Exploring the Windows Server 2003 Resource Kit: Clusfileport.dll
Exploring the Windows Server 2003 Resource Kit: Cmdhere.inf and CMGetCer.inf
Windows server security management: Security expert roundup
Windows server management with Remote Desktop
Avoid DC restoration problems with authoritative restore
Exploring the Windows Server 2003 Resource Kit: Confdisk.exe
Exploring the Windows Server 2003 Resource Kit: Clusterrecovery.exe
How to use Microsoft's IIS Diagnostics Toolkit
Microsoft Windows Server 2003 Administration Research

Windows Data Storage Administration Tools
eZines and eBooks for Windows server professionals
Windows scripting secrets for disk quota management
Top 10 Windows storage management tips of 2007
How to use the g4u network-based hard disk cloning utility
When to use third-party tools in place of NTBACKUP
CDBurnerXP 4.0: A CD/DVD/ISO freeware tool for Windows
Data backup utility mkisofs uses UDF disk-image format
Create batch file to log chkdsk results
Create custom boot sector manually with Boot Build utility
Unstoppable Copier recovers data from bad files by ignoring errors

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2004 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts