国产探花免费观看_亚洲丰满少妇自慰呻吟_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

 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 瑞安市| 汤原县| 苏尼特左旗| 阿拉善右旗| 金乡县| 光山县| 泰宁县| 连南| 芦溪县| 大洼县| 绥江县| 泾阳县| 尚志市| 三原县| 错那县| 那坡县| 吉安市| 阜城县| 迁安市| 瓮安县| 漳平市| 清水县| 宝应县| 怀化市| 舟曲县| 葫芦岛市| 昌平区| 延边| 临江市| 平度市| 乡城县| 荔波县| 浙江省| 西乌| 泸溪县| 永和县| 金寨县| 老河口市| 鸡泽县| 乌兰浩特市| 桂东县|