国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > IIS > 正文

用VBS創建IIS虛擬站點實例

2024-08-29 03:13:53
字體:
來源:轉載
供稿:網友

' ---------------------------------------------------------------------------
' creates or deletes the virtual directory http://localhost/channel7
'
' valid command line switches: -i -u -q
'   -i  install virtual directory
'   -u  remove virtual directory
'   -q  run in quiet mode
'
' ---------------------------------------------------------------------------
' see http://www.microsoft.com/windows2000/en/advanced/iis/default.asp?url=/windows2000/en/advanced/iis/htm/asp/aore8v5e.htm

option explicit

dim vpath,vname, vwshshell, vobjargs, vinstall, vremove, vquiet, i

vname = "channel7"

' get current path to folder
vpath = left(wscript.scriptfullname, instrrev(wscript.scriptfullname, "/", 15) - 1)
vpath = vpath & "/owbase"

'set wshshell = wscript.createobject("wscript.shell")
'vpath = wshshell.regread("hklm/software/channel7") & "/owbase"

vquiet = false
vinstall = false
vremove = false

set vobjargs = wscript.arguments

for i = 0 to vobjargs.count - 1
    if instr(lcase(vobjargs(i)), "i") <> 0 then
        vinstall = true
    elseif instr(lcase(vobjargs(i)), "u") <> 0 then
        vremove = true
    end if
    if instr(lcase(vobjargs(i)), "q") <> 0 then
        vquiet = true
    end if
next

if vremove then
    deletevdir vname
elseif vinstall then
    createvdir vname, vpath
end if


sub createvdir(pname, ppath)
    dim vroot, vbasedir, vwebsite, ipsecurityobj, iplist

    on error resume next

    ' get the local host default web
    set vwebsite = getobject("iis://localhost/w3svc/1")
    if not isobject(vwebsite) then
        display "unable to locate the default web site. iis must be installed and running."
        exit sub
    else
        'display vwebsite.name
    end if

    ' get the root
    set vroot = vwebsite.getobject("iiswebvirtualdir", "root")
    if (err <> 0) then
        display "unable to access root for " & vwebsite.adspath
        exit sub
    else
        'display vroot.name
    end if

    ' find or create the ow vroot.
    ' the physical path to http://localhost/ow is set to the ...<install-dir>/owbase folder
    err.number = 0 'clear error
    set vbasedir = getobject(vroot.adspath & "/" + pname)
    if err.number <> 0 then
        err.number = 0
        set vbasedir = vroot.create("iiswebvirtualdir", pname)
        vbasedir.accessread = true
        vbasedir.accessflags = 513  ' = 0x200 + 0x01 = md_access_script + md_access_read
        vbasedir.appcreate false
        vbasedir.aspallowsessionstate = false
        vbasedir.setinfo ' this section restricts access to everyone except localhost (127.0.0.1).
        'set ipsecurityobj = vbasedir.ipsecurity
        'ipsecurityobj.grantbydefault = false
        'iplist = ipsecurityobj.ipgrant
        'redim iplist(ubound(iplist) + 1)
        'iplist(ubound(iplist)) = "127.0.0.1"
        'ipsecurityobj.ipgrant = iplist
        'vbasedir.ipsecurity = ipsecurityobj
        'vbasedir.setinfo

        vbasedir.path = ppath
        vbasedir.appfriendlyname = "channel7"
        vbasedir.setinfo

        if (err <> 0) then
            display "un

|||,歡迎訪問網頁設計愛好者web開發。able to create " & vroot.adspath & "/" & pname
            exit sub
        else
            err = 0
            'display vbasedir.name
        end if
    end if

end sub


sub deletevdir(pname)
    dim vroot, vbasedir, vwebsite, ipsecurityobj, iplist
    on error resume next

    ' get the local host default web
    set vwebsite = getobject("iis://localhost/w3svc/1")
    if not isobject(vwebsite) then
        display "unable to locate the default web site. iis must be installed and running."
        exit sub
    else
        'display vwebsite.name
    end if

    ' get the root
    set vroot = vwebsite.getobject("iiswebvirtualdir", "root")
    if (err <> 0) then
        display "unable to access root for " & vwebsite.adspath
        exit sub
    else
        'display vroot.name
    end if

    err.number = 0 'clear error
    set vbasedir = getobject(vroot.adspath)

    vbasedir.delete "iiswebvirtualdir", pname
    vbasedir.setinfo

    if not vquiet then
        wscript.echo "virtual directory http://localhost/" & vbasedir.name & "/" & pname & " deleted successfully."
    end if
end sub


sub display(pmsg)
    if not vquiet then
        wscript.echo now & ". error code: " & hex(err) & " - " & pmsg
    end if
end sub

 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 高清| 临泉县| 石泉县| 额敏县| 崇阳县| 富蕴县| 景泰县| 菏泽市| 监利县| 尉氏县| 禹州市| 佛山市| 连南| 若尔盖县| 西畴县| 东平县| 文登市| 曲靖市| 阿拉善右旗| 甘孜县| 新巴尔虎右旗| 资中县| 安庆市| 民权县| 禹州市| 新密市| 兴化市| 巫山县| 大冶市| 丰原市| 宜川县| 元氏县| 息烽县| 堆龙德庆县| 淮安市| 西乌珠穆沁旗| 郴州市| 客服| 临猗县| 保康县| 巨鹿县|