Server-side invoke WinZip command line package compression for multiple files uploaded

Source: Internet
Author: User
Tags command line contains copy execution functions include variables zip
Package | server | command Line | upload | Compression 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 the Microsoft Scripting series, in short, to provide a scripting environment
In this environment, some objects are predefined, and other objects in COM can also be used.
He uses a scripting engine to interpret the script, and Microsoft itself supports VBScript and JScript,
Third parties can also develop their own scripting engines.

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
A file existing in the-F replacement zip file
-h|-? See Help
-V Create a list of compressed files information
-@list first create a file that contains all the files you want to extract, and then compress by the file name contained
............... (Other specific see Help file)
[@listfile] is the list information record for compressed files
[Files ...] Is the number of files to compress, separated by a space, or you can use a wildcard character

Cases:
Compress all files in the current directory
Wzzip Test.zip *.*
Compress all files of type txt
Wzzip Test.zip *.txt
Compress two files
Wzzip Test.zip abc.txt Def.txt
Compresses all files of type TXT except Abc.txt
Wzzip-xabc.txt Test.zip *.txt
Compressed D:\docs files and subdirectories of all types txt
WZZIP-RP Test.zip D:\docs\*.txt
Update the files in the zipit.1st to Test.zip
Wzzip-u test.zip @Zipit. LST
List contents of a compressed file
Wzzip-v Test.zip


Extract files with WZUNZIP.exe:
by format: wzunzip [options] zipfile [@listfile] [path] [files ...]
[Options] include:
-C[M] Decompression is the display file list in the DOS screen
The directory structure in the-D rebuild zip file
-F extracts only files with the same name as the current folder in the zip file, and if not, does not understand the pressure
-jhrs ignores hidden, read-only, System properties of files in a zip file
-jhrs only unpack files with hidden, read-only, system attributes
-N Unzip only the new file, if the file to be extracted is replaced by a new one that already exists.
-O do not use Yes to determine whether to replace the file
-V Create a list of compressed files information
-@list first create a file that contains all the files you want to extract, and then unzip it by the file name contained.
..........



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.