carlos
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
Code: Select all
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.
Bug: remove the path of filenames on extraction.
Second: version 5 (Windows 2000, xp):
parameters: -r -D -F:
Code: Select all
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.
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)
Code: Select all
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.
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 have this text:test\folder1\text.txt
test\folder2\text.txt
Code: Select all
text a
Code: Select all
text b
Code: Select all
CABARC.EXE -p -r test.cab test\*
Now, for show the bug:test\folder1\text.txt
test\folder2\text.txt
With the version 2.5 (nt):
Code: Select all
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.
Code: Select all
text b
Code: Select all
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.
Code: Select all
text b
Code: Select all
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.
but print:test\folder1\text.txt
test\folder2\text.txt
Code: Select all
text.txt
text.txt
Code: Select all
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 output of -D option:
Code: Select all
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:
Code: Select all
test.cab: text.txt
test.cab: text.txt
Code: Select all
Adding .\test\folder1\text.txt to Extraction Queue
Adding .\test\folder2\text.txt to Extraction Queue
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.
Code: Select all
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.
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)
----------------------------
#2 15 Jan 2014 12:57
npocmaka
so -r is the only reliable switch?
----------------------------
#3 15 Jan 2014 19:29
carlos
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)
----------------------------
#4 19 Jan 2014 15:19
Simon Sheppard
Thanks Carlos, I've added a link to this from the main Expand page