我现在实现一个功能,使用ASP代码实现IIS建立虚拟目录和相关物理目录都搞定,还有个问题怎么设置HTML主机头呢?

biaowen 2007-08-21 02:11:13
应该如何实现呢,有哪位高手弄过,指点一下,我使用下面代码实现建立虚拟目录的。
这段代码需要你在IIS里面建立一个有ADMINISTRATOR管理员权限目录才可以运行哦.
详细操作步骤:放置这短代码的IIS虚拟目录上右键 属性---目录安全性---编制-浏览 里面填上 administrator 确定就可以运行下面代码了.


这短代码只实现了虚拟目录的建立,但怎么才能加上对HTML主机头进行设置呢,就是如何才能绑上我指定的域名.
希望大虾们帮我解决下,全分送,以示感激...



<%@ Language=VBScript %>
<% Option EXPlicit %>
<Html>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>

<%
Dim strVirtualDirectoryName 'IIS虚拟目录名
Dim bolInProcessApplication '处理应用标记中的IIS
Dim objIIS 'ADSI IIS对象
Dim strVirtualDirectoryPath 'IIS虚拟目录路径
Dim objFileSystem 'VBScript文件系统对象
Dim strOwner 'NT文件夹所有者
Dim objVirtualDirectory 'ADSI IIS虚拟目录对象
Dim bolScriptPermissions 'IIS脚本权限标记
Dim strHTTPReferer 'IIS参考页
Dim strServerName 'NT本地机器名
Dim objWSH 'Windows脚本主机对象
Dim objRTC '返回
Dim strACLCommand '设置ACLs的命令行串

strVirtualDirectoryName = "union5" '虚拟目录名称和文件夹名称
strOwner = "admin"

If 1=1 Then
bolScriptPermissions = "True"
Else
bolScriptPermissions = "False"
End If

' Does this IIS application already exist in the metabase?

On Error Resume Next
Set objIIS = GetObject("IIS://localhost/W3SVC/1/Root/" & strVirtualDirectoryName)

If Err.Number = 0 Then
Response.Write ("An application with this name already exists. Click ")
Response.Write ("<A HREF=http:// " & strServerName & " /servin/default.asp>")
Response.Write ("here</A> to choose a different name.")
Response.End
End If

Set objIIS = Nothing

Set objIIS = GetObject("IIS://localhost/W3SVC/1/Root")
strVirtualDirectoryPath = objIIS.Path & "\" & strVirtualDirectoryName

Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject")

'Test to see if the folder exists in the filesystem. If not, create it

On Error Resume Next
Set Folder = objFileSystem.GetFolder(strVirtualDirectoryPath)
If Hex(Err.number) = "4C" Then
objFileSystem.CreateFolder strVirtualDirectoryPath
End If

Set objFileSystem = Nothing

'在文件系统上创建文件夹

Set objVirtualDirectory = objIIS.Create("IISWebVirtualDir",strVirtualDirectoryName)
objVirtualDirectory.AccessScript = bolScriptPermissions
objVirtualDirectory.Path = strVirtualDirectoryPath
objVirtualDirectory.SetInfo
objVirtualDirectory.AppCreate bolInProcessApplication


'Set Change Permissions for the developer using CACLS.exe
strACLCommand = "cmd /c echo y| CACLS "
strACLCommand = strACLCommand & strVirtualDirectoryPath
strACLCommand = strACLCommand & " /g " & strOwner & ":C"

Set objWSH = Server.CreateObject("WScript.Shell")
objRTC = objWSH.Run (strACLCommand , 0, True)

Set objWSH = Nothing


Response.Write("<B>执行成功</B><BR>")
Response.Write("您所创建虚拟目录物理路径 : "& strVirtualDirectoryPath & "<BR>")
Response.Write("您所创建虚拟目录名称 : "& strVirtualDirectoryName & "<BR>")
Response.Write("Script Permissions : "& bolScriptPermissions & "<BR>")
Response.Write( strOwner & " has been granted change permissions<BR>")
%>
</BODY>
</HTML>
...全文
172 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
biaowen 2007-08-21
  • 打赏
  • 举报
回复
希望大虾指点.....
biaowen 2007-08-21
  • 打赏
  • 举报
回复
期待.......
biaowen 2007-08-21
  • 打赏
  • 举报
回复
期待.....

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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