首 页文章中心下载中心繁體中文
设为首页
加入收藏
联系我们
您当前的位置:开源盛世-源代码下载网 -> 文章中心 -> 数据库类 -> MS Access -> 文章内容 退出登录 用户管理
栏目导航
· MS Access · MS SQL
· MY SQL · DB2
· Oracle · Sybase
· 数据库相关
热门文章
· Tab Control控件使用...
· 学生档案管理系统
· [图文] 排列组合公式
· UTF-8与GB2312之间的...
· DirectShow下载安装...
· Virtual PC 在PAE模...
· Windows2000终端服务...
· MapInfo上的GIS系统...
· kalman filter 卡尔...
· Windows2000终端服务...
相关文章
· Flash和Asp数据库的...
· [图文] ASP数据库连接方式大...
· ASP数据库连接方式大...
· ASP数据库连接方式大...
· [图文] ASP数据库连接方式大...
ASP数据库连接方式大全 四
作者:佚名  来源:vscodes.com整理  发布时间:2005-12-16 12:46:28  发布人:Polaris

减小字体 增大字体

有了以上的准备,那么我们现在来编写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")
%>



Regsvr32.asp

<-- '**************************************************************** '* ASP300 '* '* 版权所有: ASP300.COM 专业ASP代码交流基地 '* '**************************************************************** -->







Regsvr Functions
Insert Path to DLL Directory

">



<%
IF Request.Form("btnFileList") <> "" OR btnREG <> "" Then
Set RegisterFiles = New clsRegister
RegisterFiles.EchoB("Select File")
Call RegisterFiles.init(frmFolderPath)
RegisterFiles.EchoB("
& "REG/UNREG" & Chr(34) & ">")
IF Request.Form("btnREG") <> "" Then
Call RegisterFiles.Register(frmFilePath, frmMethod)
End IF
Set RegisterFiles = Nothing
End IF
%>





<%
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("Folder ( " & strRoot & " ) Not Found.")
Exit Sub
End IF
setRoot = oRootDir

Echo("")
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("")
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("")
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: ")
EchoB("unRegister: ")
End Sub

Function Echo(str)
Echo = Response.Write(str & vbCrLf)
End Function

Function EchoB(str)
EchoB = Response.Write(str & "
" & 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 & "
"
s = s & "Total Space: " & FormatNumber(drv.TotalSize / 1024, 0)
s = s & " Kb" & "
"
s = s & "Free Space: " & FormatNumber(drv.FreeSpace / 1024, 0)
s = s & " Kb" & "
"
Response.Write s
End Sub

下面的代码说明在 Jscript 中实现同样的功能:
function ShowDriveInfo1(drvPath)
{
var fso, drv, s ="";
fso = new ActiveXObject("scripting.FileSystemObject");
drv = fso.GetDrive(fso.GetDriveName(drvPath));
s += "Drive " + drvPath.toUpperCase()+ " - ";
s += drv.VolumeName + "
";
s += "Total Space: " + drv.TotalSize / 1024;
s += " Kb" + "
";
s += "Free Space: " + drv.FreeSpace / 1024;
s += " Kb" + "
";
Response.Write(s);
}


End of《ASP数据库连接方式大全 四》

[] [返回上一页] [打 印] [收 藏]
 
∷相关“ASP数据库连接方式大全 四”文章评论∷
(评论内容只代表网友观点,与本站立场无关!) [更多评论...]
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 网站目录 鄂ICP备06007162
开源盛世 版权所有Copyright © 2003-2005 VSCodes.Com. All Rights Reserved.