Remote DLL registration using ASP

Source: Internet
Author: User

A foreigner is really smart. I want to get this method too. If you are interested, try it. But if the server security of the other party is very good, this Code may not work, but no matter what, it's also good to study ,:)

<% 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 class = FS>
<Legend class = legend> regsvr 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, fr1_hod)
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
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.