Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script to set sychronization bit of files

Status
Not open for further replies.

czarj

Technical User
Apr 22, 2004
130
US
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!

Code:
      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

--- You must not fight too often with one enemy, or you will teach him all your tricks of war.
 
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?


Code:
Const SYNCHRONIZE = &h100000
If wmiAce.AccessMask And SYNCHRONIZE > 0 Then
 '...???...
End If

--- You must not fight too often with one enemy, or you will teach him all your tricks of war.
 
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!

Code:
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


--- You must not fight too often with one enemy, or you will teach him all your tricks of war.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top