Solved

Help with scripting share permissions

Posted on 2011-03-03
9
668 Views
Last Modified: 2012-05-11
Hi all, My developers have written a VB script  that shares all listed subfolders with "Everyone - Full Control". However, when running this on Server 2008 R2 x64, it only applies the "Read " bit. Please review the script to see what can be changed, or at least advise on a second script that can be ran afterwards. Thank you!

==========================================================================

Dim strFolder, strHome, strUser
Dim intRunError, objShell, objFSO
Dim strComputer
Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 9999

'---------- CHANGE DIRECTORY PATH HERE ----------
strFolder = "E:\home"
'------------------------------------------------
strComputer = "."

Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFolder)
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewShare = objWMIService.Get("Win32_Share")

SetPermissions objFSO.GetFolder(strFolder)

Function SetPermissions(Folder)

    For Each Subfolder in Folder.SubFolders
   
          'Reset Folder ACL
            If objFSO.FolderExists(strFolder) Then
                  intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls """ & Subfolder.Path & """ /t /c /g everyone:F", 2, True)
            End If
   
          'Share Folder
          intRunError = objNewShare.Create(Subfolder.Path,Subfolder.Name,FILE_SHARE,MAXIMUM_CONNECTIONS,"")  

    Next
      
End Function
0
Comment
Question by:entint
  • 5
  • 4
9 Comments
 
LVL 10

Expert Comment

by:Martin_J_Parker
Comment Utility
I suspect you are running foul of the sort of User Access Control crap that Vista started.
Does it run correctly if you right click it and "run as administrator"?
0
 

Author Comment

by:entint
Comment Utility
Tried that and UAC is turned off.
0
 
LVL 10

Expert Comment

by:Martin_J_Parker
Comment Utility
Your VB program appears to work fine on my Win 2008 R2 x64 server!
I do have admin privileges (not logged in as administrator but as AD user with admin rights).
I assume that your user does have full priv. in the E:\Home folder?
0
 

Author Comment

by:entint
Comment Utility
Yes I am logged in as a Domain Admin. Server is on the Domain, so this group is in the local Administrators group. UAC and Windows Firewall are both off, so what else could be in the way. I have been tested this on new OS installs, not off an image, only clan installs.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 10

Expert Comment

by:Martin_J_Parker
Comment Utility
Unless you have some strange non-standard cacls command in your path I don't see any reason why it should fail.  My system is pretty bog standard and fairly recently clean installed as well - although the AD and group permissions are set centrally so I can't be 100% sure that it hasn't been modified!
0
 

Author Comment

by:entint
Comment Utility
No CACL command in DOS, only running the script above.No added paremeters if this is what you mean
0
 
LVL 10

Accepted Solution

by:
Martin_J_Parker earned 125 total points
Comment Utility
Yep - and as far as I can see it should work!  

If you change it from E:\Home to some other newly created folder (create a new E:\temp\folders for example) do you get the same results?

Is E: a standard local NTFS disk?  I assume it's not a share from somewhere else?
0
 

Author Comment

by:entint
Comment Utility
Admins have Full Control at the parent level. I tried to create a new folder and verified permissions with and without inheritance. I even took my account as owner. What could be so differnet about all of our servers here compared to yours?
0
 

Author Comment

by:entint
Comment Utility
Can this be reopened? No one ever replied
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoresIncreasing challenge 10 57
array11 challenge 16 50
strCopies  challenge 17 73
Path of Workbook 3 44
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now