Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DIR Command and Folder Permissions

Status
Not open for further replies.

Sylv4n

Technical User
Feb 27, 2002
83
GB
Hi,
I am Shelling two commands out to Dos and then exporting that into a text fille then reading in that file, Just wandering if anyone had a better solution.

COMMAND1
Dir " & Range("Search") & " /A:D /S /B >C:\Temp\DirCommand.txt

The /A:D will bring back only Directorys (Only things I need)
The /S Will Go through ALL subdirectories
The /B Will give it a Bare Format so no sizes etc.

COMMAND 2
SHOWACLS """ & SearchString & """ >C:\Temp\ACLResult.txt

This will bring Back the fodler security settings for the folder (SearchString), it brings it back in the followin format:

c:\DirectoryA
Work\D_INFOSYS Change [RWXD]
Work\M_Admins Full Control [ALL]
Work\M_GroupData Full Control [ALL]
Work\Domain Admins Full Control [ALL]

Where it is in the format:
Domain\Group

Domain is not requiired and is removed from these results.

I am just looking for better/Quicker ways to do this. Thanks
 
Hi,

You can use the Dir command (VBA function) with the vbDirectory argument to pick up the directories in a while loop, to do the first task.

John
 
Excelent, works, with the added bonus that you can see what it is doing.
The Code used was the following:
(Where Cell A2 in "Data" Sheet contained C: or watever)

Dim lngWriteLine As Long
Dim lngReadLine As Long
Dim strSearchPath As String
Dim strReturnedFolder As String

lngWriteLine = 3
lngReadLine = 2

While Len(Sheets(&quot;Data&quot;).Cells(lngReadLine, &quot;A&quot;)) <> 0
strSearchPath = Sheets(&quot;Data&quot;).Cells(lngReadLine, &quot;A&quot;)
'Add A &quot;\&quot;
If Right$(strSearchPath, 1) <> &quot;\&quot; Then strSearchPath = strSearchPath & &quot;\&quot;
strReturnedFolder = Dir(strSearchPath, vbDirectory) ' Retrieve the first entry.

Do While strReturnedFolder <> &quot;&quot; ' Start the loop.
' Ignore the current directory and the encompassing directory.
If strReturnedFolder <> &quot;.&quot; And strReturnedFolder <> &quot;..&quot; Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(strSearchPath & strReturnedFolder) And vbDirectory) = vbDirectory Then
Sheets(&quot;Data&quot;).Cells(lngWriteLine, &quot;A&quot;) = strSearchPath & strReturnedFolder ' Display entry only if it
lngWriteLine = lngWriteLine + 1
'The Below Line is not really required but it looks good :0)
Sheets(&quot;Data&quot;).Cells(lngWriteLine, &quot;A&quot;).Select
End If ' it represents a directory.
End If
strReturnedFolder = Dir ' Get next entry.
Loop
lngReadLine = lngReadLine + 1
Wend
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top