How do I call the WinZip command line on the server side to pack and compress multiple files that are uploaded? (Tian le original)

Source: Internet
Author: User
Tags command line execution functions include variables pack zip
Package | server | command Line | upload | compression | Original How to call the WinZip command line on the server side to pack and compress multiple files uploaded?

To solve this problem, first of all, to understand the Windows scripting Host, referred to as wsh! Here is a reference to Microsoft's explanation:
************************************************************************
* WSH is one of a series of Microsoft scripting technologies, which simply provides a scripting environment, *
* In this environment, some objects are predefined, and other objects in COM can also be used. *
* He used a scripting engine to interpret the script, and Microsoft itself supported VBScript and JScript, *
* A third party can also develop its own scripting engine. *
************************************************************************
The point is that you first make up some script files (Microsoft comes with examples, suffixes. vbs or. js),
Then use a program to explain to him the execution, this program is called Windows Scripting Host, program
The name is Wscript.exe (or command line Cscript.exe), you can check your machine
There are no these two documents, you know there is no WSH. (Win2000 is under winnt/system32/)
This is much like a batch file, except that it is not a command line, but a script written in the script language.

Here's a brief introduction to WSH. Several built-in objects include:

1. Objects provided by Wscript.exe
Wscript is exposed as a Wscript to the scripting engine.
WSHArguments is not public; accessed through the WScript.Arguments property. Into

2. Objects provided by Wshom.ocx.
WshShell an automatic object. ProgID is Wscript.wshshell.
(Note: This is what we want to use, can execute DOS command)
WSHNetwork an automatic object. ProgID is wscript.wshnetwork.
Wshshortcut is not public; accessed through the Wshshell.createshortcut method.
Wshurlshortcut is not public; accessed through the Wshshell.createshortcut method.
Wshcollection is not public; accessed through wshnetwork.enumnetworkdrives or Wshnetwork.enumprinterconnection methods.
Wshenvironment is not public; accessed through the Wshshell.environment property.
Wshspecialfolders is not public; accessed through the Wshshell.folder property.

They can mainly complete the acquisition of environment variables, network landing, drive mapping, fast-truncated way to create,
program loading, special folders (such as system folders) information acquisition functions.

If you have a system that supports COM parts such as ADO, you can also use the
The following example demonstrates opening WordPad to view a text file, creating a text file and writing a
Paragraph, you can copy him to the Clipboard, save it as a. vbs suffix, and then double-click him,

' Test.vbs
'*********************
' Start the program with the Shell object below
'*********************
Set WshShell = WScript.CreateObject ("Wscript.Shell")
Wshshell.run ("notepad" & Wscript.scriptfullname)


'***********************************************
' Manipulate text files with COM objects Scripting.FileSystemObject
'***********************************************
Set fs = WScript.CreateObject ("Scripting.FileSystemObject")
Set a = fs. CreateTextFile ("C:\testfile.txt", True)
A.writeline ("This is a test.") ")
A.close

can also be used in web programming languages such as ASP.
<script language= "Vbscript.encode" runat=server>
' Start the program with a Shell object
Set WshShell = server. CreateObject ("Wscript.Shell")
issuccess = Wshshell.run ("D:\winnt\system32\cmd.exe", 1, true)
If issuccess = 0 Then
Response.Write "Command executed successfully! "
Else
Response.Write Command Execution failed! Insufficient permissions or the program cannot run in DOS
End If
</script>
Note:
1. Which Runat=server must have
2.Set WshShell = WScript.CreateObject ("Wscript.Shell")
To change to set WshShell = Server. CreateObject ("Wscript.Shell"),
3. Parameter 1 represents SW_SHOWNORMAL, activates and displays a window. If the window is minimized or maximized, revert to its original size and position.
The 4.TRUE represents an error returning execution, false, or continuing without waiting for the end of the process for the specified script to be executed.
5. Call WSH's built-in objects, as you can call functions and procedures.
such as Call Wshshell.run ("D:\winnt\system32\cmd.exe", 1, true)

If you are interested in WSH and want to know more, please see
Http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsconwshbasics.asp
http://www.dev-club.com/club/bbs/showEssence.asp?id=11136

Now let's take a closer look at how to compress and decompress the file!
As you all know, WinZip is easy to extract and compress files, but how do you call them through the program and the command line?
Of course, WinZip's authors have developed
WinZip Command Line Support Add-On Version 1.0
We can go to http://www.winzip.com/wzcline.htm to download wzcline.exe!
The premise is that the machine must be installed winzip8.0 or later version of the support, if you are not winzip8.0, go
http://www.winzip.com/download.htm Download!

After downloading, you can install it directly!
WinZip command line Help files and program Wzzip.exe,wzunzip are generated in the WinZip directory. Exe.
You can start running in the call:
such as: "C:\Program Files\winzip\wzzip" Myfile.zip
You can also copy two files here to any directory, running directly under the DOS window
such as: Wzzip.exe Myfile.zip
You can add set Path=c:\windows;c:\program files\winzip to the system's environment variables;
You can go anywhere without joining the road after the call!

Now for a quick look at the basic usage of two commands in Help
Compress files with WZZIP.exe:
General format: wzzip [options] zipfile [@listfile] [files ...]
[Options] include:
-A default operation, compressed file
-a+ compressed files and deletes files to compress
-b[drive|path] is to create a temporary compressed file on another drive
-D Delete the destination file specified in the zip file
-e<x|n|f|s|0> is set compression ratio, X max, 0 min
-F &AMP;NB



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.