DOWNLOAD THE CODE:
Download the Code 38942.zip

GetAccess.cmd
Showacls.exe and net.exe provide a foundation for the script GetAccess.cmd. This script produces a text file that lists all the files and folders to which the specified user or group has access in the specified directory and all its subdirectories. When you launch the script, you must provide three parameters: the username or group name for which you're performing the audit (username_or_groupname), the path to the directory you want to scan (path_to_scan), and the name of the output file (outputfile). You can include the optional /d switch if you want to audit only folders and not files. You can also include the optional /verbose switch if you want the console to display what the script is doing when it runs. Thus, the command that launches the script has the syntax

GetAccess.cmd
username_or_groupname
path_to_scan outputfile
[/d] [/verbose]

The script's logic is simple. It operates as follows:

  1. The script deletes the output file if it already exists. To accomplish this task, the script uses the command
  2. If Exist %outputfile% Del
    %outputfile% /q
  3. The script prepares the switches for the Dir command. As Listing 2 shows, the dirflag variable defines the switches according to the parameters you provide when you launch the script. The /s switch tells the Dir command to show all contents, including subdirectories, and the /b switch tells the Dir command to provide the output in bare format (i.e., without header or summary information). If you specified the /d parameter when you launched the script, the script adds the /ad switch to signify that you want to display directories only.
  4. Prev. page     1 [2] 3     next page



    You must log on before posting a comment.

    If you don't have a username & password, please register now.

    Reader Comments

    The script did not show how to combine every list into one working .bat or cmd file...

    Kevin Chen

    I've been using your script to audit directory permissions but I've come accross a flaw. If a user is in a Global Group which is a member of a Local Group, the script does not appear to work. Example: C:\Support ==> Access granted to TLocalGroup TLocalGroup Members TGlobalGroup TGlobalGroup Members Joe User If I run the getaccess.cmd command on Joe User it does not detect Joe User has access to that script. If I run it against TGlobalGroup it works.

    Mike Cropsey

 
 

ADS BY GOOGLE