オンライン圧縮・解凍のためのASPコード
まず、フルコードから見てみましょう。
<! --
Name -ASP online decompression, compression tool
copyright --Codedevlib (www.jb51.net)
-->
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<title> Welcome to the ASP Online Decompression, Compression Tool</title>
<body>
<TABLE border=0 width=80% align=center cellspacing=1 cellpadding=3 style="FONT-FAMILY: Verdana;font-size:14px;BORDER: #000000 1px solid;background-color:#f7f7f7">
<tr>
<th width="100%" height="24" bgcolor="#33CCFF"> </th>
</tr>
<tr>
<td bgcolor="#33CCFF">
<%
Server.ScriptTimeout=99999
Dim winrar,cmddir
Winrar="C:\Program Files\WinRAR\Winrar.exe" 'The address of the compressed file (Winrar)
cmddir="%windir%\system32\cmd.exe" 'The address of cmd.exe (command prompt)
user="csisp" 'the user name of this program
pwd="csisp" 'the program's login, compression, decompression password, please be sure to modify (at least 8-bit combination of passwords to be safe enough!)
Form("user")=user and request.Form("pwd")=pwd then
response.write "Path to this folder: "&Server.Mappath(". ")&"<br>"
from=request.Form("from")
where=request.Form("where")
if from<>"" and where<>"" then
Dim a,b,Shell,Running,Runcode,Cmd
if instr(where,":")=0 then a=Server.mappath(""&where&""") else a=where
if instr(from,":")=0 then b=Server.mappath(""&from&""") else b=from
'response.Write b
if right(b,1)<>"\" and left(right(b,4),1)<>". " then b=b&".rar"
On Error Resume Next
Set Shell = Server.CreateObject("WScript.Shell")
If request.QueryString("action")=1 then 'Decompress
if not ReportFileStatus(b)then Response.Write("Not found "&b&"May not exist! "):Response.End()
Running= cmddir&" /c """&winrar&""" x -ibck -t -y -o+ -p"&pwd&" " 'Set up run command for decompression.
Cmd=Running&b&" "&a&"\"
elseif request.QueryString("action")=0 then 'Compress file
if (not ReportFileStatus(a)) and (not ReportFolderStatus(a)) then Response.Write("Not found "&a&"May not exist! "):Response.End()
Cmd= cmddir&" /c del /f /q "&b
Runcode = Shell.Run(Cmd,1,True)
Runing= cmddir&" /c ""&winrar&"""" a -ibck -y -ep -o+ -p"&pwd&" " 'Compress.
Cmd=Running&b&" "&a
else 'Delete the file
Cmd= cmddir&" /c del /f /q "&b
end if
Runcode = Shell.Run(Cmd,1,True)
Runing = Shell.Run(cmddir&" /c taskkill /im winrar.exe",1,false)
Runing = Shell.Run(cmddir&" /c exit",1,false)
Set Shell=nothing
ErrInfo
%>
<%else%>
<form name="frm" method="post" action="?action=1" style="BORDER: #d9d9d9 1px solid;background-color :#f7f7f7">
--------------------------------------<strong>Unzip the file</strong>---------------------------------------
<br>
<br>
Please enter the address of the rar zip file at
<input name="from" value="1.rar" size="50"><br>
Unzip to: <input name="where" value=". " size="50">
Please use an absolute path to the folder and add "\" <br>. to the end;
<br>
<input name="submit" type="submit" value=" unpack "> <input type="hidden" name="user" value="user" quot; value="<%=request.Form("user")%>">
<input type="hidden" name="pwd" value="<%=request.Form("pwd")%>">
</FORM>
<form name="frm" method="post" action="?action=0" style="BORDER: #d9d9d9 1px solid;background-color :#f7f7f7">
--------------------------------------<strong>zip file</strong>---------------------------------------<br>
<br>
Please enter the address of the file you want to zip here.
<input name="where" value=". /data/dvbbs7#.mdb" size="50">
You can also enter the folder<br>
<br>
Storage path and new file name: <input name="from" value=". /data/1.rar" size="50">
Automatically overwrite files with the same name<br>
<br>
<input name="submit" type="submit" value=" press " > <input type="hidden" name="user& quot; value="<%=request.Form("user")%>">
<input type="hidden" name="pwd" value="<%=request.Form("pwd")%>">></FORM>
<%
ErrInfo
end if
else
login()
end if
Sub ErrInfo
if not isempty(Runcode) and Runcode=0 Then
Response.Write("Operation successfully executed, you submitted the following operation: <br>"& Cmd)
elseif not isempty(Runcode) then
Response.Write("Operation execution failed! Maybe you don't have enough privileges or the program can't run under DOS (command prompt), you submitted the following action: <br>" & Cmd)
else
end if
If Err Then
Command The combination of characters to be run by WinRAR represents the function.
switch Toggles the definition of the specified type of operation, compression strength, compressed file type, etc.
compression file The name of the compression file to be processed.
file The name of the file to process.
List file A list file is plain text containing the names of the files to be processed. The file name should be started in the first volume. Comments can be added to the list file using the // character followed by a comment. For example, you can include two columns of strings to create backup.lst:c:/work/doc/*.txt //backup text document c:/work/image/*.bmp //backup image c:/work/misc and then run: winrar a backup @backup.lst You can specify both in the command line a normal file name and a list file name.
The unzip path is used only with the commands e and x. Indicates where to add the decompressed files. If the folder does not exist, it will be created automatically.
List of alphabetic commands.
a Add file to zip file
c Add comments to the zip file
d Delete files from zip file
e Unzip the zip file from the zip file, ignoring the path
f Refresh the files in the zip file
i Find the string in the zip file
k Lock the zip file
m Move files and folders to the zip file
r Repair damaged zip files
rc Rebuild lost volumes
rn rename the zip file
rr[N] Add data recovery record
rv[N] Create recovery volume
s[name] Convert a compressed file to a self-extracting file type
s- Remove the self-extracting module
t Test compressed files
u Update the file from the zip file
x Unzip the zip file from the zip file with the full path name
In fact, the key point in the program code is to use Server.CreateObject("Wscript.Shell") to execute CMD.EXE, CMD.EXE to run RAR.EXE through the WINRAR command to execute the decompression of the file and the compressed file.
III. List of programs
List of ZIP.ASP programs.
<%
'main folder contains cmd.exe rar.exe Example: file to be compressed (*.mdb)
'The compressed directory is main/data.rar
on error resume next
unzip_path=Server.mappath("main")&"/"
Set WshShell = server.CreateObject("Wscript.Shell")
IsSuccess = WshShell.Run ("winrar a "&unzip_path&"data
"&unzip_path&"*.mdb",1, False)
'WinRAR <command> -<switch1> -<switchN> <compress file> <file... > <@ListFile... >
<DecompressPath/>
' Command: A - Add to zip file
if IsSuccess = 0 Then
Response.write " Command executed successfully! "
" else
Response.write " Command execution failed! Permissions are not sufficient or the program could not be run"
end if
if err.number <> 0 then
Response.Write "<p> Error number: " & Err.number
Response.Write "<p> Reason: " & Err.description
Response.Write "<p>Error source: " & Err.Source
Response.Write
end if
%>
List of UNZIP.ASP programs.
<%
'main folder contains cmd.exe rar.exe file to be decompressed (*.rar)
'The directory where the uncompressed file will be stored is main
on error resume next
unzip_path=Server.mappath("main")&"/"
Set WshShell = server.CreateObject("Wscript.Shell")
IsSuccess = WshShell.Run ("winrar x -r -o+ "&unzip_path&"*.rar
"&unzip_path&"",1, False)
'WinRAR <command> -<switch1> -<switchN> <compress file> <file... > <@ListFile... >
<DecompressPath/>
' Commands: X - decompress files from the full path in the zip file
' Switches: -R - concatenate subfolders
'Switch: -O+ - overwrite existing files
'Switch: -O- - do not overwrite existing files
if IsSuccess = 0 Then
Response.write " Command executed successfully! "
else
Response.write " Command execution failed! Permissions are not sufficient or the program could not be run"
end if
if err.number <> 0 then
Response.Write "<p> Error number: " & Err.number
Response.Write "<p> Reason: " & Err.description
Response.Write "<p>Error source: " & Err.Source
Response.Write
end if
%>
IV. Conclusion
EXE and CMD.EXE files in ASP programming to compress and decompress the files in the website online. The implementation method is simple and the program code is small, so it can be used for practical programming. Especially in the case of having your own server is extremely practical and convenient. The above program runs under Windows2000Sever and IIS5.0.
関連
-
JSONデータを扱うASP実装コード
-
asp バッチの追加・変更・削除操作のサンプルコード
-
msxml3.dll Error 800c0019 システムエラー:-2146697191 解決策
-
数字を漢数字(大文字の金額)に変換するASP機能
-
perl スクリプティング スタディガイド - 読書メモ
-
Perl の Getopt::Long モジュールを使用して、ユーザーのコマンドライン引数を受け取ります。
-
スペースがセパレータである場合の perl qw 問題の解決法
-
Perlのファイルハンドルの説明
-
perl変数$/の使用方法について説明します。コンテキストが行モードのとき、$/は行を区別するものを定義します。
-
PerlのSort関数の使い方まとめと使用例
最新
-
nginxです。[emerg] 0.0.0.0:80 への bind() に失敗しました (98: アドレスは既に使用中です)
-
htmlページでギリシャ文字を使うには
-
ピュアhtml+cssでの要素読み込み効果
-
純粋なhtml + cssで五輪を実現するサンプルコード
-
ナビゲーションバー・ドロップダウンメニューのHTML+CSSサンプルコード
-
タイピング効果を実現するピュアhtml+css
-
htmlの選択ボックスのプレースホルダー作成に関する質問
-
html css3 伸縮しない 画像表示効果
-
トップナビゲーションバーメニュー作成用HTML+CSS
-
html+css 実装 サイバーパンク風ボタン
おすすめ
-
プロセス分析によるhttpsリクエストのチャールズベースクローリング
-
Net coreのホットプラグ機構とアンインストールに関する問題点ヘルプガイド
-
提案内容を改善するために、データベースを実行するaspプログラムの効率化
-
Webform 組み込みオブジェクト セッションオブジェクト、アプリケーショングローバルオブジェクト、ViewState 詳細
-
asp は整数の mod を受け取り、小数点以下がある場合は自動的に 1 を加算します。
-
iis7でaspの行番号が不正確な問題の解決法
-
ASPでフォルダーの存在を検出し、存在しない場合は自動的に作成する方法
-
SharePoint Server 2019の新機能をご紹介します。
-
従来のいくつかの方法によるASPエラーの捕捉
-
perl による生物学的突然変異のランダムシミュレーションコード