茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    vbs通過wmi修改文件文件夾的ntfs權(quán)限
    來源:易賢網(wǎng) 閱讀:1321 次 日期:2016-06-22 09:47:29
    溫馨提示:易賢網(wǎng)小編為您整理了“vbs通過wmi修改文件文件夾的ntfs權(quán)限”,方便廣大網(wǎng)友查閱!

    使用wmi修改文件文件夾的ntfs權(quán)限實現(xiàn)方法,需要的朋友可以參考下

    使用wmi修改文件文件夾的ntfs權(quán)限, 代碼:

    代碼如下:

    struser = guests

    strpath = d:\\abc.txt

    retval = addpermission(struser,strpath,r,true)

    '-------------------------------------------------------------------------

    '用于給文件和文件夾添加一條權(quán)限設(shè)置.返回值: 0-成功,1-賬戶不存在,2-路徑不存在

    'struser表示用戶名或組名

    'strpath表示文件夾路徑或文件路徑

    'straccess表示允許權(quán)限設(shè)置的字符串,字符串中帶有相應(yīng)字母表示允許相應(yīng)權(quán)限: r-讀,c-讀寫,f-完全控制

    'blinherit表示是否繼承父目錄權(quán)限.true為繼承,false為不繼承

    function addpermission(struser,strpath,straccess,blinherit)

    set objwmiservice = getobject(winmgmts:\\.\root\cimv2)

    set fso = createobject(scripting.filesystemobject)

    '得到win32_sid并判斷用戶/組/內(nèi)置賬戶是否存在

    set colusers = objwmiservice.execquery(select * from win32_account where name='&struser&')

    if colusers.count<>0 then

    for each objuser in colusers

    strsid = objuser.sid

    next

    else

    addpermission = 1

    exit function

    end if

    set objsid = objwmiservice.get(win32_sid.sid='&strsid&')

    '判斷文件/文件夾是否存在

    pathtype =

    if fso.fileexists(strpath) then pathtype = file

    if fso.folderexists(strpath) then pathtype = folder

    if pathtype = then

    addpermission = 2

    exit function

    end if

    '設(shè)置trustee

    set objtrustee = objwmiservice.get(win32_trustee).spawninstance_()

    objtrustee.domain = objsid.referenceddomainname

    objtrustee.name = objsid.accountname

    objtrustee.sid = objsid.binaryrepresentation

    objtrustee.sidlength = objsid.sidlength

    objtrustee.sidstring = objsid.sid

    '設(shè)置ace

    set objnewace = objwmiservice.get(win32_ace).spawninstance_()

    objnewace.trustee = objtrustee

    objnewace.acetype = 0

    if instr(ucase(straccess),r) > 0 then objnewace.accessmask = 1179817

    if instr(ucase(straccess),c) > 0 then objnewace.accessmask = 1245631

    if instr(ucase(straccess),f) > 0 then objnewace.accessmask = 2032127

    if pathtype = file and blinherit = true then objnewace.aceflags = 16

    if pathtype = file and blinherit = false then objnewace.aceflags = 0

    if pathtype = folder and blinherit = true then objnewace.aceflags = 19

    if pathtype = folder and blinherit = false then objnewace.aceflags = 3

    '設(shè)置sd

    set objfilesecsetting = objwmiservice.get(win32_logicalfilesecuritysetting.path='&strpath&')

    call objfilesecsetting.getsecuritydescriptor(objsd)

    blse_dacl_auto_inherited = true

    if (objsd.controlflags and &h400) = 0 then

    blse_dacl_auto_inherited = false

    objsd.controlflags = (objsd.controlflags or &h400)

    '自動繼承位置位,如果是剛創(chuàng)建的目錄或文件該位是不置位的,需要置位

    end if

    if blinherit = true then

    objsd.controlflags = (objsd.controlflags and &hefff)

    '阻止繼承復(fù)位

    else

    objsd.controlflags = (objsd.controlflags or &h1400)

    '阻止繼承位置位,自動繼承位置位

    end if

    objolddacl = objsd.dacl

    redim objnewdacl(0)

    set objnewdacl(0) = objnewace

    if isarray(objolddacl) then

    '權(quán)限為空時objolddacl不是集合不可遍歷

    for each objace in objolddacl

    if (blse_dacl_auto_inherited=false and blinherit=true) or ((objace.aceflags and 16)>0 and (blinherit=true) or (lcase(objace.trustee.name)=lcase(struser))) then

    'do nothing

    '當(dāng)自動繼承位置位為0時即使時繼承的權(quán)限也會顯示為非繼承,這時所有權(quán)限都不設(shè)置

    '當(dāng)自動繼承位置位為0時,在繼承父目錄權(quán)限的情況下不設(shè)置繼承的權(quán)限.賬戶和需要加權(quán)限的賬戶一樣時不設(shè)置權(quán)限

    else

    ubd = ubound(objnewdacl)

    redim preserve objnewdacl(ubd+1)

    set objnewdacl(ubd+1) = objace

    end if

    next

    end if

    objsd.dacl = objnewdacl

    '提交設(shè)置修改

    call objfilesecsetting.setsecuritydescriptor(objsd)

    addpermission = 0

    set fso = nothing

    end function

    更多信息請查看腳本欄目
    易賢網(wǎng)手機(jī)網(wǎng)站地址:vbs通過wmi修改文件文件夾的ntfs權(quán)限
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2026國考·省考課程試聽報名

    • 報班類型
    • 姓名
    • 手機(jī)號
    • 驗證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機(jī)站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報警專用圖標(biāo)