

解压文件用WZUNZIP.exe :
通过格式:wzunzip [options] zipfile [@listfile] [path] [files...]
[options]包括:
-c[m] 解压是显示文件列表在dos屏幕中
-d 重建zip文件中的目录结构
-f 只解压在zip文件里同目前文件夹存在的同名的文件,如果没有则不解压
-jhrs 忽视zip文件里的文件的隐藏、只读、系统属性
-Jhrs 只解压带有隐藏、只读、系统属性的文件
-n 只解压叫新的文件,如果要解压的文件比已存在的新则替换。
-o 不用通过yes来确定是否要替换文件
-v 创建一个压缩文件的列表信息
-@list 先创建一个包含所有要解压的文件的文件,然后按所包含的的文件名解压
...............(其他具体看帮助文件)
例如:
创建所有文件到当前目录下
wzunzip test.zip
从test.zip中创建abc.txt到当前目录下
wzunzip test.zip abc.txt
创建在test.zip中的目录结构及文件到当前目录下
wzunzip -d test.zip
创建在test.zip中的目录结构及文件到c:\docs下
wzunzip -d test.zip c:\docs从test.zip中创建包含在files.ist中的文件名的文件
wzunzip test.zip @files.lst
显示test.zip的文件列表内容
wzunzip -v test.zip
显示压缩文件中所有类型为txt的文件列表内容
wzunzip -v test.zip *.txt
有了以上的准备,那么我们现在来编写VBS来执行文件解压和压缩就易如反掌了:
'test.vbs
'*********************
'上面用SHELL对象启动程序
'*********************
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.Run ("c:\wzzip.exe c:\test.zip c:\a.txt c:\b.txt")
'test.asp
'*********************
'上面用SHELL对象启动程序
'*********************
<script language="VBScript.Encode" runat=server>
'上面用SHELL对象启动程序
Set WshShell = server.CreateObject("Wscript.Shell")
IsSuccess = WshShell.Run (" c:\wzzip.exe c:\test.zip c:\a.txt c:\b.txt" ,1, true)
if IsSuccess = 0 Then
Response.write " 命令成功执行!"
else
Response.write " 命令执行失败!权限不够或者该程序无法在DOS状态下运行"
end if
</script>
利用ASP远程注册DLL的方法
--------------------------
<% Response.Buffer = True %>
<% Server.ScriptTimeout = 500
Dim frmFolderPath, frmFilePath
frmFolderPath = Request.Form("frmFolderPath")
frmFilePath = Request.Form("frmDllPath")
frmMethod = Request.Form("frmMethod")
btnREG = Request.Form("btnREG")
%>
<HTML>
<HEAD>
<TITLE>Regsvr32.asp</TITLE>
<STYLE TYPE="TEXT/CSS">
.Legend {FONT-FAMILY: veranda; FONT-SIZE: 14px; FONT-WEIGHT: bold; COLOR: blue}
.FS {FONT-FAMILY: veranda; FONT-SIZE: 12px; BORDER-WIDTH: 4px; BORDER-COLOR: green;
MARGIN-LEFT:2px; MARGIN-RIGHT:2px}
TD {MARGIN-LEFT:6px; MARGIN-RIGHT:6px; PADDING-LEFT:12px; PADDING-RIGHT:12px}
</STYLE>
</HEAD>
<BODY>
<FORM NAME="regForm" METHOD="POST">
<TABLE BORDER=0 CELLSPACING=6 CELLPADDING=6 MARGINWIDTH=6>
<TR>
<TD VALIGN=TOP>
<FIELDSET ID=FS1 NAME=FS1 Functions</LEGEND>
Insert Path to DLL Directory<BR>
<INPUT TYPE=TEXT NAME="frmFolderPath" value="<%=frmFolderPath%>"><BR>
<INPUT TYPE=SUBMIT NAME=btnFileList value="Build File List"><BR>
<%
IF Request.Form("btnFileList") <> "" OR btnREG <> "" Then
Set RegisterFiles = New clsRegister
RegisterFiles.EchoB("<B>Select File</B>")
Call RegisterFiles.init(frmFolderPath)
RegisterFiles.EchoB("<BR><INPUT TYPE=SUBMIT NAME=btnREG value=" & Chr(34) _
& "REG/UNREG" & Chr(34) & ">")
IF Request.Form("btnREG") <> "" Then
Call RegisterFiles.Register(frmFilePath, frmMethod)
End IF
Set RegisterFiles = Nothing
End IF
%>
</FIELDSET>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<%
Class clsRegister
Private m_oFS
Public Property Let oFS(objOFS)
m_oFS = objOFS
End Property
Public Property Get oFS()
Set oFS = Server.CreateObject("Scripting.FileSystemObject")
End Property
Sub init(strRoot) 'Root to Search (c:, d:, e:)
Dim oDrive, oRootDir
IF oFS.FolderExists(strRoot) Then
IF Len(strRoot) < 3 Then 'Must Be a Drive
Set oDrive = oFS.GetDrive(strRoot)
Set oRootDir = oDrive.RootFolder
Else
Set oRootDir = oFS.GetFolder(strRoot)
End IF
Else
EchoB("<B>Folder ( " & strRoot & " ) Not Found.")
Exit Sub
End IF
setRoot = oRootDir
Echo("<SELECT NAME=" & Chr(34) & "frmDllPath" & Chr(34) & ">")
Call getAllDlls(oRootDir)
EchoB("</SELECT>")
BuildOptions
End Sub
Sub getAllDlls(oParentFolder)
Dim oSubFolders, oFile, oFiles
Set oSubFolders = oParentFolder.SubFolders
Set opFiles = oParentFolder.Files
For Each oFile in opFiles
IF Right(lCase(oFile.Name), 4) = ".dll" OR Right(lCase(oFile.Name), 4) = ".ocx" Then
Echo("<OPTION value=" & Chr(34) & oFile.Path & Chr(34) & ">" _
& oFile.Name & "</Option>")
End IF
Next
On Error Resume Next
For Each oFolder In oSubFolders 'Iterate All Folders in Drive
Set oFiles = oFolder.Files
For Each oFile in oFiles
IF Right(lCase(oFile.Name), 4) = ".dll" OR Right(lCase(oFile.Name), 4) = ".ocx" Then
Echo("<OPTION value=" & Chr(34) & oFile.Path & Chr(34) & ">" _
& oFile.Name & "</Option>")
End IF
Next
Call getAllDlls(oFolder)
Next
On Error GoTo 0
End Sub
Sub Register(strFilePath, regMethod)
Dim theFile, strFile, oShell, exitcode
Set theFile = oFS.GetFile(strFilePath)
strFile = theFile.Path
Set oShell = CreateObject ("WScript.Shell")
IF regMethod = "REG" Then 'Register
oShell.Run "c:\WINNT\system32\regsvr32.exe /s " & strFile, 0, False
exitcode = oShell.Run("c:\WINNT\system32\regsvr32.exe /s " & strFile, 0, False)
EchoB("regsvr32.exe exitcode = " & exitcode)
Else 'unRegister
oShell.Run "c:\WINNT\system32\regsvr32.exe /u/s " & strFile, 0, False
exitcode = oShell.Run("c:\WINNT\system32\regsvr32.exe /u/s " & strFile, 0, False)
EchoB("regsvr32.exe exitcode = " & exitcode)
End IF
Cleanup oShell
End Sub
Sub BuildOptions
EchoB("Register: <INPUT TYPE=RADIO NAME=frmMethod value=REG CHECKED>")
EchoB("unRegister: <INPUT TYPE=RADIO NAME=frmMethod value=UNREG>")
End Sub
Function Echo(str)
Echo = Response.Write(str & vbCrLf)
End Function
Function EchoB(str)
EchoB = Response.Write(str & "<BR>" & vbCrLf)
End Function
Sub Cleanup(obj)
If isObject(obj) Then
Set obj = Nothing
End IF
End Sub
Sub Class_Terminate()
Cleanup oFS
End Sub
End Class
%>
利用CDONTS发送邮件的ASP函数
<%
'Last Updated By Recon On 05/14/2001
'On Error Resume Next
'利用CDONTS组件在Win2k上发送邮件
'发送普通邮件
SendMail "admin@ny.com", "iamchn@263.net", "Normal Mail!", "Please check the attatchment!", 2, 0, "C:\Love.txt"
'发送HTML邮件
Dim m_fso, m_tf
Dim m_strHTML
Set m_fso = Server.CreateObject("SCRIPTING.FILESYSTEMOBJECT")
Set m_tf = m_fso.OpenTextFile("C:\Mail.htm", 1)
m_strHTML = m_tf.ReadAll
'Write m_strHTML
Set m_tf = Nothing
Set m_fso = Nothing
SendMail "admin@ny.com", "iamchn@263.net", "HTML Mail!", m_strHTML, 2, 1, Null
'参数说明
'strFrom : 发件人Email
'strTo : 收件人Email
'strSubject : 信件主题
'strBody : 信件正文
'lngImportance : 信件重要性
' : 0 - 低重要性
' : 0 - 中等重要性(默认)
' : 0 - 高重要性
'lngAType : 信件格式
' : 为1时将邮件正文作为HTML(此时可以发送HTML邮件)
'strAttach : 附件的路径
Sub SendMail(strFrom, strTo, strSubject, strBody, lngImportance, lngAType, strAttach)
Dim objMail
Set objMail = Server.CreateObject("CDONTS.NEWMAIL")
With objMail
.From = strFrom
.To = strTo
.Subject = strSubject
.Body = strBody
.Importance = lngImportance
If lngAType = 1 Then
.BodyFormat = 0
.MailFormat = 0
End If
If IsEmpty(strAttach) = False And IsNull(strAttach) = False Then
.AttachFile strAttach
End If
.Send
End With
Set objMail = Nothing
End Sub
%>
处理驱动器和文件夹
使用 FileSystemObject (FSO) 对象模式,可以有计划地处理驱动器和文件夹,就像在 Windows 资源管理器中交互式地处理它们一样。可以复制和移动文件夹,获取有关驱动器和文件夹的信息,等等。
获取有关驱动器的信息
可以用 Drive 对象来获得有关各种驱动器的信息,这些驱动器是实物地或通过网络连接到系统上的。它的属性可以用来获得下面的信息内容:
驱动器的总容量,以字节为单位(TotalSize 属性)
驱动器的可用空间是多少,以字节为单位(AvailableSpace 或 FreeSpace 属性)
哪个号被赋给了该驱动器(DriveLetter 属性)
驱动器的类型是什么,如可移动的、固定的、网络的、CD-ROM 或 RAM 磁盘(DriveType 属性)
驱动器的序列号(SerialNumber 属性)
驱动器使用的文件系统类型,如 FAT、FAT32、NTFS 等等(FileSystem 属性)
驱动器是否可以使用(IsReady 属性)
共享和/或卷的名字(ShareName 和 VolumeName 属性)
驱动器的路径或根文件夹(Path 和 RootFolder 属性)
请考察示例代码,来领会如何在 FileSystemObject 中使用这些属性。
Drive 对象用法示例
使用 Drive 对象来收集有关驱动器的信息。在下面的代码中,没有对实际的 Drive 对象的引用;相反,使用 GetDrive 方法来获得现有 Drive 对象的引用(在这个例子中就是 drv)。
下面示例示范了如何在 VBScript 中使用 Drive 对象:
Sub ShowDriveInfo(drvPath)
Dim fso, drv, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set drv = fso.GetDrive(fso.GetDriveName(drvPath))
s = "Drive " & UCase(drvPath) & " - "
s = s & drv.VolumeName & "<br/>"
s = s & "Total Space: " & FormatNumber(drv.TotalSize / 1024, 0)
s = s & " Kb" & "<br/>"
s = s & "Free Space: " & FormatNumber(drv.FreeSpace / 1024, 0)
s = s & " Kb" & "<br/>"
Response.Write s
End Sub
下面的代码说明在 JScript 中实现同样的功能:
function ShowDriveInfo1(drvPath)
{
var fso, drv, s ="";
fso = new ActiveXObject("Scripting.FileSystemObject");
drv = fso.GetDri
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] 下一页
网页吧·中国站长第一门户