怎么自动创建虚拟目录?

ahr 2003-07-22 10:42:37
怎么自动创建iis虚拟目录?
...全文
297 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
banner90 2003-08-05
  • 打赏
  • 举报
回复
看不懂
lcm 2003-08-04
  • 打赏
  • 举报
回复
能否写一个完整的例子?
ahr 2003-07-22
  • 打赏
  • 举报
回复
好,谢谢了。 我的信箱ahr@163.net
andrew00 2003-07-22
  • 打赏
  • 举报
回复
应该是可以的~
但不如自己直接设置IIS拉
我在哪里看到过用程序来控制的,我找到发给你~
ahr 2003-07-22
  • 打赏
  • 举报
回复
我想做安装程序,把我的asp文件安装到一个目录后,自动在iis上创建一个指向我的目录的虚拟目录。
sw47 2003-07-22
  • 打赏
  • 举报
回复
怎么个自动法?
Cooly 2003-07-22
  • 打赏
  • 举报
回复
再给一些例子

<%
Dim WebServerRootObj
Dim VDirObj
Dim WritePerm

' Open the object for the first virtual Web server root
Set WebServerRootObj = GetObject("IIS://MyComputer/W3SVC/1/Root")

' Deny write access for all directories and files
' for the server (except those already specifically set)
' Using the Put method
WebServerRootObj.Put "AccessWrite", False

' Save the changed value to the metabase
WebServerRootObj.SetInfo

' Get a directory subordinate to the Web server root. Note that this line of code assumes
' Vdir1 has already been created.
Set VDirObj = GetObject("IIS://MyComputer/W3SVC/1/Root/Vdir1/Dir1a")

' Overwrite the inherited value for write access
' using the dot method equivalent to Put
VDirObj.AccessWrite = True

' Save the changed value to the metabase
VDirObj.SetInfo
%>

ADSI ASP Script
The next example shows you how to write a customized script to create a virtual directory with Read, Script, and Directory browsing permission.

<%
'''''''''''''''''''''''''''''''''
' ADSI ASP Sample Program
' This is a sample of how to create a virtual directory using ADSI.
'
'''''''''''''''''''''''''''''''''
Option Explicit
On Error Resume Next

'''''''''''''''''''''''
' First, open the path to the Web server you are
' trying to add a virtual directory to.

Dim ServObj
Dim VdirObj
Dim Testpath

Set ServObj = GetObject("IIS://LocalHost/w3svc/1/Root")
if (Err <>0) then
Response.Write "GetObject (""IIS://LocalHost/w3svc/1/Root"") Failed! <br>"
Response.Write "Error! " & Err.Number & "(" & Hex(Err.Number) & "): " & Err.Description & "<br>"
Response.End
end if

'''''''''''''''''''''''
' Second, Create the virtual directory (Vdir) path
Set VdirObj = ServObj.Create("IIsWebVirtualDir", "MyVdir")
VdirObj.SetInfo
if (Err<>0) then
Response.Write "CreateObject (""IIS://LocalHost/w3svc/1/Root/MyVdir"") Failed!<br>"
Response.Write "Error! " & Err.Number & "(" & Hex (Err.Number) & "): " & Err.Description &

"<br>"
Response.End
end if

''''''''''''''''''''''''
' Finally, create a Path variable containing the virtual root path and
' set the permissions to read, script, and directory browsing
VdirObj.AccessRead = True
VdirObj.AccessScript = True
VdirObj.EnableDirBrowsing = True
Testpath = "C:\Temp"
VdirObj.Put "Path", (Testpath)

VdirObj.SetInfo
if (Err<> 0) then
Response.Write "Put (""Path"") Failed!"
Response.Write "Error! " & Err.Number & "(" & Hex (Err.Number) & "): " & Err.Description &

"<br>"
Response.End
end if

Response.Write "VDIR successfully created"

''''''''''''''''''''''''
' The minimum amount necessary to create a virtual directory has now
' been completed. If you need to add more, do it here.

%>

Cooly 2003-07-22
  • 打赏
  • 举报
回复
给你一个FTP的例子,WebSite差不多

Public Function CreateFtpSite(ByVal strComputerName As String, strIPAddress As String, ByVal strRootDirectory As String, ByVal strServerComment As String, ByVal iPortNum As Integer, ByVal bStart As Boolean, ByVal iSiteNumber As Integer, ByVal strUserName As String, ByVal strPassword As String)
Dim bDone
Dim oFtpServer
Dim oFtpSite
Dim oMsFtpSvc
Dim oNewFtpServer
Dim oNewDir
Dim oNewDirInfo

Err.Clear

On Error Resume Next

'取FTP服务地址
Set oMsFtpSvc = GetObject("IIS://" & strComputerName & "/MSFTPSVC")

If Err.Number <> 0 Then
MsgBox "不能打开: " & "IIS://" & strComputerName & "/MSFTPSVC"
Exit Function
End If

'创建新的FTP站点.其中站点索引号为递增号码,一般默认FTP站点为1.在实际使用中,可以判断一共有多少个站点.然后索引号加一即可.
'如果需要创建虚拟目录,操作完全一样.

Set oNewFtpServer = oMsFtpSvc.Create("IIsFtpServer", iSiteNumber)
oNewFtpServer.SetInfo
If (Err.Number <> 0) Then
MsgBox "不能创建FTP站点. 可能是站点索引号已存在. 站点索引号: " & iSiteNumber
Exit Function
End If

Err.Clear

'设置新FTP站点的属性
oNewFtpServer.ServerBindings = strIPAddress & ":" & iPortNum & ":"
oNewFtpServer.ServerComment = strServerComment
oNewFtpServer.SetInfo

Set oNewDir = oNewFtpServer.Create("IIsFtpVirtualDir", "ROOT")
oNewDir.Path = strRootDirectory

oNewDir.AccessRead = True '允许读访问
oNewDir.AccessWrite = True '允许写访问
oNewDir.SetInfo

'设置匿名访问账号
oMsFtpSvc.AllowAnonymous = True
oMsFtpSvc.AnonymousUserName = strUserName
oMsFtpSvc.Anonymouspassword = strPassword
oMsFtpSvc.SetInfo

'启动新的FTP站点
If bStart = True Then
Err.Clear
oNewFtpServer.Start
If Err.Number <> 0 Then
MsgBox strServerComment & "无法自动启动,请察看是否有使用相同端口的FTP服务正在运行"
End If
End If

MsgBox "FTP站点创建成功! : " & "IIS://" & strComputerName & "/MSFTPSVC/" & iSiteNumber

End Function
buddyli 2003-07-22
  • 打赏
  • 举报
回复
看看已解决的问题!
liuzxit 2003-07-22
  • 打赏
  • 举报
回复
通過installShield打包可以做到,不過我沒了那份資料,你就用installShield搜索一下可以找到的
ruanjiancomputer 2003-07-22
  • 打赏
  • 举报
回复
我也要jiangjiecomputer@163.com

8,327

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 IIS
社区管理员
  • IIS
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧