心跳的回忆

标题: 利用ASP远程注册DLL的方法 [打印本页]

作者: ghost    时间: 2003-3-10 10:27
标题: 利用ASP远程注册DLL的方法
利用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
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("
") 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 %>




欢迎光临 心跳的回忆 (http://www.hsrbbs.com/) Powered by Discuz! X3.1