|
通过ASP远程注册自己的组件(3) 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 %>
|