SoFunction
Updated on 2025-04-14

ASP essence source code collection (five-year summary) page 5/20


How to call winzip command line on the server side to package and compress multiple uploaded files
-------------------------------------------
How to pack and compress multiple uploaded files by calling winzip command line on the server side?
To solve this problem, we must first understand Windows Scripting Host, referred to as WSH! Here is a quote from Microsoft's explanation:
************************************************************************
* WSH is a type of Microsoft's scripting technology series. Simply put, it provides a scripting environment, *
* In this environment, some objects are predefined, and other objects in COM can also be used. *
* He uses a script engine to interpret and execute scripts. Microsoft itself supports VBSCRIPT and JSCRIPT, *
* Third parties can also develop their own scripting engines. *
************************************************************************
To be specific, you first compile some script files (Microsoft comes with some examples, with suffixes.vbs or .js).
Then use a program to explain and execute it, and this program is called Windows Scripting Host.
The name is (or command line), you can check your machine
If you have these two files in it, you will know if there is WSH. (win2000 is under winnt/system32/)
This is very similar to a batch file, except that the file is not a command line, but a script written in the script language.
Let’s briefly introduce several built-in objects that come with WSH, including:
1. Object provided by
Wscript is exposed to the scripting engine as Wscript.
WshArguments Not public; accessed through attributes. enter
2. Object provided by .
WshShell Automatic object. ProgID is .
(Note: This is what we want to use, you can execute the dos command)
WshNetwork Automatic object. ProgID is .
WshShortcut is not published; accessed through the method.
WshUrlShortcut is not disclosed; accessed through the method.
WshCollection is not disclosed; accessed via or method.
WshEnvironment is not published; accessed through the property.
WshSpecialFolders Not public; accessed through the property.
They can mainly complete the acquisition of environment variables, network login, drive mapping, and quick intercept creation.
Program loading, special folders (such as system folders) information acquisition and other functions.
If your system supports ADO and other COM components, you can also use it.
The following example demonstrates opening the WordPad to view the text file, creating a text file and writing a
You can copy it to the writing board, then save it with .vbs as the suffix, and then double-click it.
'
'*********************
'The following is to start the program with the SHELL object
'*********************
Set WshShell = ("")
("notepad " & )
'***********************************************
'Manipulate text files with COM objects
'***********************************************
Set fs = ("")
Set a = ("c:\", True)
("This is a test.")

It can also be applied in web programming languages ​​such as Asp
<script language="" runat=server>
'The above uses the SHELL object to start the program
Set WshShell = ("")
IsSuccess = ("D:\winnt\system32\" ,1, true)
if IsSuccess = 0 Then
"The command was executed successfully!"
else
"Command execution failed! Insufficient permissions or the program cannot run in DOS"
end if
</script>
Note:
1. The runat=server must have
WshShell = ("")
To change to Set WshShell = (""),
3. Parameter 1 represents SW_SHOWNORMAL, activates and displays a window. If the window is minimized or maximized, it will be restored to its original size and position.
Represents an error that returns execution, False or specify that the script continues to execute without waiting for the process to end.
5. Calling the built-in object of WSH, it can be called like calling functions and procedures.
For example call ("D:\winnt\system32\" ,1, true)
If you are interested in WSH and want to know more, please check it out
/library/?url=/library/en-us/script56/html/
/club/bbs/?id=11136
Now let's get back to the point and see how to compress and decompress files!
Everyone knows that winzip is easy to decompress and compress files, but how to call them through programs and command lines?
Of course the author of winzip has developed
WinZip Command Line Support Add-On Version 1.0
Everyone can go/download it!
The premise is that the machine must install winzip8.0 or higher support. If you are not winzip8.0, go to
/ download!
After downloading, just install it!
The winzip command line help file and program will be generated in the winzip directory.
You can start running calls:
For example: "c:\program files\winzip\wzzip"
You can also copy two files here to any directory and run them directly under the dos window.
like:
You can add set path=c:\windows;c:\program files\winzip;
You can call it anywhere without adding a pass!
Now let’s briefly understand the basic usage of the two commands in the help
Use to compress files:
General format: wzzip [options] zipfile [@listfile] [files...]
[options] include:
-a Default operation, compressed file
-a+ compress the file and delete the file to be compressed
-b[drivepath] is to create temporary compressed files on another drive
-d Delete the target file specified in the zip file
-e<xnfs0> is to set the compression ratio, x is the maximum and 0 is the minimum
-f Replace the file that exists in the zip file
-h-? View help
-v Create a list of compressed files
-@list Create a file that contains all the files to be decompressed, and then compress it by the included file name
............. (For other details, please refer to the help file)
[@listfile] is a list information record of compressed files
[files...] is the multiple files to be compressed, separated by spaces, or a wildcard
example:
Compress all files in the current directory
wzzip *.*
Compress all files of type txt
wzzip *.txt
Compress two files
wzzip
Compress all files of type txt except
wzzip - *.txt
Compress all files and subdirectories of type txt under D:\docs
wzzip -rp d:\docs\*.txt
Update the file in zipit.1st to
wzzip -u @
List the list of compressed files
wzzip -v
Use to unzip the file:
By format: wzunzip [options] zipfile [@listfile] [path] [files...]
[options] include:
-c[m] decompression is to display the file list in the dos screen
-d Reconstruct the directory structure in the zip file
-f Only decompress files with the same name as the current folder in the zip file. If not, decompress them.
-jhrs Ignore the hidden, read-only, and system properties of files in zip files
-Jhrs only decompress files with hidden, read-only, and system properties
-n Only decompress the new file, replace if the file to be decompressed is newer than the existing one.
-o No need to use yes to determine whether to replace the file
-v Create a list of compressed files
-@list Create a file that contains all the files to be decompressed, and then decompress it by the included file name
............. (For other details, please refer to the help file)
For example:
Create all files to the current directory
wzunzip
Created from it to the current directory
wzunzip
Create the directory structure and file in the current directory
wzunzip -d
Create the directory structure and file in c:\docs
wzunzip -d c:\docs creates a file containing the file name from it
wzunzip @
The content of the displayed file list
wzunzip -v
Display the contents of all file types txt in the compressed file
wzunzip -v *.txt
With the above preparation, it will be easy for us to write VBS to perform file decompression and compression:
'
'*********************
'The above uses the SHELL object to start the program
'*********************
Set WshShell = ("")
("c:\ c:\ c:\ c:\")
'
'*********************
'The above uses the SHELL object to start the program
'*********************
<script language="" runat=server>
'The above uses the SHELL object to start the program
Set WshShell = ("")
IsSuccess = (" c:\ c:\ c:\ c:\" ,1, true)
if IsSuccess = 0 Then
"The command was executed successfully!"
else
"Command execution failed! Insufficient permissions or the program cannot run in DOS"
end if
</script>
Previous page1234567891011121314151617181920Next pageRead the full text