Is possible to compress/archive a directory with all of its sub-directories and files in a single file from cmd.exe ? I know 开发者_如何学Gothere are a lot of utilities available but I need to perform the operation only with the windows default utilities . I'm running windows server 2003 .
Although the old makecab doesn't store a real directory structure, you can command the output directories for each file if you really need it. The procedure is more cumbersome than using a modern utility, but can be done.
For doing this you should create a .ddf file.
The manual for the old makecab has been removed from the web by MS. I found a copy here.
In page 33 of the makecab manual you will find:
DestinationDir=path
Path prefix to store in cabinet file for each file in the cabinet.
Default: .Set DestinationDir= ; Default is no path prefix
pathis concatenated with a path separator (“\”) and the target file name on
File Copy Commands to produce the file name that is stored in cabinet file.
EXTRACT.EXE will use this file name as the default name when the file is extracted.
Examples:
.Set DestinationDir=SYSTEM ; Following files get SYSTEM prefix
bin\ARIAL.TTF ; Name in cabinet is SYSTEM\ARIAL.TTF
.Set DestinationDir= ; No prefix
bin\ARIAL.TTF ; Name in cabinet is ARIAL.TTF
HTH!
There's really very little you can do as there's no command-line compression as part of Windows as standard.
The closest thing I can think of is to use the backup program NTBackup.
If there's any way you can install a utility I'd strongly recommend 7zip which I've had good experience of scripting with.
精彩评论