设置文件同步位的脚本 [英] script to set sychronization bit of files
本文介绍了设置文件同步位的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我试图弄清楚如何编写将通过目录的文件并重置文件上的同步位.查看下面的fsecurity输出,我需要Sychonrize = 1.坦白说,我不是Windows程序员,也不知道子例程的外观.我想我需要使用''objFile.Attributes'',但我不确定.任何帮助将不胜感激!
Hi Folks,
I''m trying to figure out how to script something that will go through a directory and reset the sychronization bit on a file. Looking at the fsecurity output below I need Sychonrize=1. Frankly I am not a windows programmer and am not sure how the subroutine should look. I would imagine I would need to make use of ''objFile.Attributes'' but i''m not really sure. Any help would be appreciated!
Allow - NT AUTHORITY\Authenticated Users - 0x000200a1
0... .... .... .... .... .... .... .... = Generic Read
.0.. .... .... .... .... .... .... .... = Generic Write
..0. .... .... .... .... .... .... .... = Generic Execute
...0 .... .... .... .... .... .... .... = Generic All
.... ..0. .... .... .... .... .... .... = Maximum Allowed
.... ...0 .... .... .... .... .... .... = System Security
.... .... ...0 .... .... .... .... .... = Synchronize
.... .... .... 0... .... .... .... .... = Write Owner
.... .... .... .0.. .... .... .... .... = Write DAC
.... .... .... ..1. .... .... .... .... = Read Control
.... .... .... ...0 .... .... .... .... = Delete
.... .... .... .... .... ...0 .... .... = Write Attributes
.... .... .... .... .... .... 1... .... = Read Attributes
.... .... .... .... .... .... .0.. .... = Delete Child
.... .... .... .... .... .... ..1. .... = Execute
.... .... .... .... .... .... ...0 .... = Write EA
.... .... .... .... .... .... .... 0... = Read EA
.... .... .... .... .... .... .... .0.. = Append
.... .... .... .... .... .... .... ..0. = Write
.... .... .... .... .... .... .... ...1 = Read
推荐答案
因此,看起来好像需要使用wmiAce.AccessMask.我可以看到如何获取当前值,但不确定如何设置它.有什么建议吗?
So it looks like wmiAce.AccessMask needs to be used. I can see how to get the current value, but not sure how to set it. Any suggestions?
Const SYNCHRONIZE = &h100000
''...
If wmiAce.AccessMask And SYNCHRONIZE > 0 Then
''...
End If
因此,我认为应该可以使用脚本.但是,我仍然缺少如何设置属性值的概念.有任何建议,谢谢!
So I have the making''s of a script that should work. But, i''m still missing the concept of how to set the value of the attribute. Any suggestions, Thanks!
Const SYNCHRONIZE = &h100000
strPath = "C:\Windows\Temp"
Set objfso = CreateObject("Scripting.FileSystemObject")
If objfso.FolderExists(strPath) Then ''Make sure folder exists
Set objFolder = objfso.GetFolder(strPath)
Set colFiles = objFolder.Files ''Enumerate files
If colFiles.Count > 0 Then
For Each objFile In colFiles
Call SetSYNCFlag(objFile) ''Call subroutine for each file found.
Next
Else ''colFiles collection was empty
WScript.Echo "No files in folder", objFolder.Path
End If
Else ''Folder path could not be found
WScript.Echo "The specified folder", strPath, "does not exist"
End If
Sub SetSYNCFlag(objFile)
On Error Resume Next ''Disable automatic error handling
Err.Clear ''Clear the StdErr object before continuing
If wmiAce.AccessMask And SYNCHRONIZE > 0 Then
WScript.Echo "correct attribute already set", objFile
Else
<<<<< Need to set the value of SYNCHRONIZE to 1 >>>>>>
<<<<< HELP >>>>>
End If
End Sub
这篇关于设置文件同步位的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文