#1 15 Jan 2014 05:03

carlos
Member
From: Chile
Registered: 04 Nov 2008
Posts: 232
Website

[Undocumented] [Bugs] Expand.exe (more about it)

Hello.
Writing my utility bhx 3.1 I use many time the different versions of expand.exe. Time ago, I write somethings here: http://ss64.org/viewtopic.php?id=1597
But, in this post I write more.

I tested almost, version 2.5 (Windows nt), version 5 (Windows 2000, xp), version 6 (Windows 7, 8).
And this three versions are differents. Versions prior 6 have a bug handling cab with filenames that preserve a path.

Basically there a 2 cabinet file types:
-a cabinet file that have 1 file inside it. aka: "Single-Cabinet"
-a cabinet file that have 2 or more files inside it. aka: "Multi-Cabinet"

First: version 2.5 (Windows nt) :
parameters: only -r

Microsoft (R) File Expansion Utility  Version 2.50
Copyright (C) Microsoft Corp 1990-1994.  All rights reserved.

Expands one or more compressed files.

EXPAND [-r] Source Destination
EXPAND -r Source [Destination]

  -r            Rename expanded files.
  Source        Source file specification.  Wildcards may be used.
  Destination Destination file | path specification.
                Destination may be a directory.
                If Source is multiple files and -r is not specified,
                Destination must be a directory.

This version cannot decompress cabinet files compressed with LZX, only support MSZIP and QUANTUM. Can decompress Single-Cabinet and Multi-Cabinet using the -r parameter.
Bug: remove the path of filenames on extraction.


Second: version 5 (Windows 2000, xp):
parameters: -r -D -F:

Microsoft (R) Utilidad de expansión de archivos versión 5.00.2134.1
Copyright (C) Microsoft Corp 1990-1999.  Reservados todos los derechos.

Expande uno o más archivos comprimidos.

EXPAND [-r] Origen Destino
EXPAND -r Origen [Destino]
EXPAND -D Origen.cab [-F: Archivos]
EXPAND Origen.cab -F: Archivos de destino


  -r            Cambia el nombre de los archivos expandidos.
-D             Muestra una lista de archivos en el origen
   Origen       Especificación del archivo de origen.  Se pueden usar comodines.
-F: Archivos   Nombre de archivos que se expanden desde un .CAB.
  Destino       Archivo de destino | ruta de acceso.
                El destino puede ser un directorio.
                Si el origen son varios archivos y no se especifica -r,
                el destino debe ser un directorio.

This version support LZX compression, QUANTUM and MSZIP and NONE.
Can decompress Single-Cabinet and and Multi-Cabinet. But for Multi-Cabinet the option -F: should be used obligatory.
Bug: remove the path of filenames on extraction and in the output of -D option.

version 6 (Windows 7 and 8) :
parameters: -R -I -D -F: (in this -r is accepted as -R)

Microsoft (R) File Expansion Utility  Version 6.2.9200.16384
Copyright (c) Microsoft Corporation. All rights reserved.

Expands one or more compressed files.

EXPAND [-R] Source Destination
EXPAND -R Source [Destination]
EXPAND -I Source [Destination]
EXPAND -D Source.cab [-F:Files]
EXPAND Source.cab -F:Files Destination

  -R            Rename expanded files.
  -I            Rename expanded files but ignore directory structure.
  -D            Display list of files in source.
  Source        Source file specification.  Wildcards may be used.
  -F:Files      Name of files to expand from a .CAB.
  Destination   Destination file | path specification.
                Destination may be a directory.
                If Source is multiple files and -r is not specified,
                Destination must be a directory.

This version keeps the posible directory structure of a filename inside the cab in extraction. It creates the needed directorys.
Bug: remove the path from filenames in the output of -D option, but use it on the extraction.

For example and demostration of the bugs in versions prior to 6:
I will create this directory structure:

test\folder1\text.txt
test\folder2\text.txt

test\folder1\text.txt have this text:

text a

test\folder2\text.txt have this text:

text b

All this inside a folder called test. Then with cabarc command:

CABARC.EXE -p -r test.cab test\*

then out test.cab have this filenames inside it:

test\folder1\text.txt
test\folder2\text.txt

Now, for show the bug:

With the version 2.5 (nt):

C:\examples>EXPAND.EXE -r test.cab
Microsoft (R) File Expansion Utility  Version 2.50
Copyright (C) Microsoft Corp 1990-1994.  All rights reserved.

Expandiendo test.cab a text.txt.
Expandiendo test.cab a text.txt.

It creates none folder and a two files in the current folder, overwriting the files with the same name. Then, we found in this case only 1 file called text.txt that have this text:

text b

With version 5 (Windows 2000 xp):

C:\examples>EXPAND.EXE -r test.cab -F:* .
Microsoft (R) Utilidad de expansión de archivos versión 5.00.2134.1
Copyright (C) Microsoft Corp 1990-1999.  Reservados todos los derechos.

Expandiendo test.cab a .\text.txt.
Expandiendo test.cab a .\text.txt.

2 total de archivos.

The same  that in version 2.5, it really expand 2 files, but because this ignore the directory structure, it overwrite files. Then, only 1 file called text.txt is found with this text:

text b

Output of -D option:

C:\examples>EXPAND2K.EXE -D test.cab
Microsoft (R) Utilidad de expansión de archivos versión 5.00.2134.1
Copyright (C) Microsoft Corp 1990-1999.  Reservados todos los derechos.

test.cab: text.txt
test.cab: text.txt

2 total de archivos.

it should be print :

test\folder1\text.txt
test\folder2\text.txt

but print:

text.txt
text.txt

Version 6: (Windows seven, 8):

C:\tcc>EXPAND -r test.cab -F:* .
Microsoft (R) File Expansion Utility  Version 6.2.9200.16384
Copyright (c) Microsoft Corporation. All rights reserved.

Adding .\test\folder1\text.txt to Extraction Queue
Adding .\test\folder2\text.txt to Extraction Queue

Expanding Files ....

Expanding Files Complete ...
2 files total.

The version 6, create the necessary folders for expand all the files. But in the -D option in the list of filenames, cut off the path of the filenames.

The output of -D option:

C:\examples>EXPAND -D test.cab
Microsoft (R) File Expansion Utility  Version 6.2.9200.16384
Copyright (c) Microsoft Corporation. All rights reserved.

test.cab: text.txt
test.cab: text.txt

2 files total.

If you compare the output of -D option and the output on extraction:
-D:

test.cab: text.txt
test.cab: text.txt

Extraction:

Adding .\test\folder1\text.txt to Extraction Queue
Adding .\test\folder2\text.txt to Extraction Queue

The bug of -D option in version 6 means that you cannot view if a cabinet have paths inside it until you extract it.

In the version 6 you can ignore the path of the filenames, extracting to the current directory, like prior versions, using the -I option, but unlike prior version, abort the operation and not overwrite.

C:\examples>EXPAND -I test.cab /F:* .
Microsoft (R) File Expansion Utility  Version 6.2.9200.16384
Copyright (c) Microsoft Corporation. All rights reserved.

Adding .\text.txt to Extraction Queue
Adding .\text.txt to Extraction Queue

Expanding File test.cab Incomplete, Error Code=0x800700b7
Error Description: Cannot create a file when that file already exists.


2 files total.

It says: "2 files total.", but It create none files, because error.



The cabinet format specification says that a file can have a flag attribute 0x40 that means that the file should be executed after extraction. This flag is ignored in all version of expand that I test. This means, that a file with this flag will not be executed after extraction unlike the specification.

Last edited by carlos (20 Jan 2014 03:33)

Offline

#2 15 Jan 2014 12:57

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 331

Re: [Undocumented] [Bugs] Expand.exe (more about it)

so -r is the only reliable switch?


http://www.facebook.com/npocmaka

Offline

#3 15 Jan 2014 19:29

carlos
Member
From: Chile
Registered: 04 Nov 2008
Posts: 232
Website

Re: [Undocumented] [Bugs] Expand.exe (more about it)

npocmaka wrote:

so -r is the only reliable switch?

@npocmaka: versions prior 6 strip the path of filenames on extraction, and extract all to current directory overwriting files. If you cabinet file not have filenames with path (as normally), all versions of expand will works fine, if this cabinet is a multi-cab you need add the option /F:* since version 5. But if you cabinet file have filenames with path inside, the only reliable version of expand for expand the cabinet is the version 6. The version 6 as version 5 for show the list of filenames are not realiable (version 2.5 not have this option).

Last edited by carlos (15 Jan 2014 19:30)

Offline

#4 19 Jan 2014 15:19

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 774
Website

Re: [Undocumented] [Bugs] Expand.exe (more about it)

Thanks Carlos, I've added a link to this from the main Expand page http://ss64.com/nt/expand.html

Offline

Board footer

Powered by FluxBB