Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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
Posted 21-Feb-12 2:42am
spores126
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 390
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 21 Feb 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100