Link to home
Start Free TrialLog in
Avatar of MichaelBalack
MichaelBalackFlag for Singapore

asked on

How to get to know the shared folder share/ntfs permissions by using vbscript?

This is another vbs script to find out the local computer for any shared folder. Please see the script contents,

   strComputer = "."
 
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService= objSWbemLocator.ConnectServer(".", "root\cimv2")
 
Set colShares = objWMIService.ExecQuery("Select * from Win32_Share Where Type=0")
 
For each objShare in colShares
 
    Wscript.Echo "Name: " & objShare.Name  & vbCrLf _
                       & "Path: " & objShare.Path & vbCrLf  _
                       & "Type: " & objShare.Type  & vbCrLf _
                       & "Allow Maximum: " & objShare.AllowMaximum & vbCrLf _
                       & "Maximum Allowed: " & objShare.MaximumAllowed & vbCrLf _
                       & "Caption: " & objShare.Caption  
Wscript.Echo "---------------------------------"
Next

Using this script, I manage to get the list of shared folders. How about if I want to know the share/ntfs permissions of the shared folder, what should be added into the script?

Thanks in advance
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

VBScript is not appropriate for this

Use SetACL to export the NTFS permissions. It can also do the share permissions
https://helgeklein.com/setacl/
Avatar of MichaelBalack

ASKER

Hi Shaun,

Besides SetACL, can we use icacls? We do not allowed to use 3rd party tools according to company IT policy.
ASKER CERTIFIED SOLUTION
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for expert - Shaun, that's works