I’m working on a program that will disable access to shared folders on a document server if the hard drive is getting close to being full. Currently, I am just renaming them to something different to prevent the app server from being able to send more documents over. I’m wondering if there is a way to somehow lock down a folder programmatically, either setting it to read only, or disable its share status. From what I’ve seen, changing a folder to read-only directly in windows doesn’t prevent new files from being copied into it. Anyone have any ideas on how to do this? My current code looks like this:
Private Function MoveShares(ByVal strOldLocation As String, ByVal strNewLocation As String) As Boolean
Dim objFSO As New FileSystemObject
If objFSO.FolderExists(strOldLocation) Then
LogAction "Moving " & strOldLocation & " to " & strNewLocation
objFSO.MoveFolder strOldLocation, strNewLocation
End If
Set objFSO = Nothing
End Function
Pretty basic, but I’m hoping I can do this in a subtler way.
For the shared folder, I ended up editing the registry to “rename” the share itself, not the folder. I did this by reading the registry entry data, deleting the entry, and writing the data to a new entry. I also had to restart the computer browser and server services in order for the server to acquire the new share name. This prevents the app server from sending documents because it can’t find a share with the old name. I also had to convert the security entry values from decimal back to hexadecimal before writing them to the new entry, and wait between stopping and restarting services to make sure they had finished before moving on the to next service.