Solved

Help with scripting share permissions

Posted on 2011-03-03
9
710 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 10

Expert Comment

by:Martin_J_Parker
ID: 35028761
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
ID: 35032299
Tried that and UAC is turned off.
0
 
LVL 10

Expert Comment

by:Martin_J_Parker
ID: 35034873
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:entint
ID: 35148273
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
 
LVL 10

Expert Comment

by:Martin_J_Parker
ID: 35148601
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
ID: 35149381
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
ID: 35149952
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
ID: 35449262
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
ID: 35802234
Can this be reopened? No one ever replied
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Starting up a Project

630 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