/build/static/layout/Breadcrumb_cap_w.png

Enumerate

i want to Enumerate the profile on the computer and set what attributes are on those profile


strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colCSItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objCSItem In colCSItems
WScript.Echo "User Name: " & objCSItem.UserName





Set colFolders = objWMIService. _
ExecQuery("Select * from Win32_Directory" )

For Each objFolder in colFolders

Wscript.Echo "Archive: " & objFolder.Archive
Wscript.Echo "Caption: " & objFolder.Caption
Wscript.Echo "Compressed: " & objFolder.Compressed
Wscript.Echo "Compression method: " & objFolder.CompressionMethod
Wscript.Echo "Creation date: " & objFolder.CreationDate
Wscript.Echo "Encrypted: " & objFolder.Encrypted
Wscript.Echo "Encryption method: " & objFolder.EncryptionMethod
Wscript.Echo "Hidden: " & objFolder.Hidden
Wscript.Echo "In use count: " & objFolder.InUseCount
Wscript.Echo "Last accessed: " & objFolder.LastAccessed
Wscript.Echo "Last modified: " & objFolder.LastModified
Wscript.Echo "Name: " & objFolder.Name
Wscript.Echo "Path: " & objFolder.Path
Wscript.Echo "Readable: " & objFolder.Readable
Wscript.Echo "System: " & objFolder.System
Wscript.Echo "Writeable: " & objFolder.Writeable
Next
Next

0 Comments   [ + ] Show comments

Answers (6)

Posted by: brenthunter2005 18 years ago
Fifth Degree Brown Belt
4
You know the "Rate post" below the "Reply" and message, that was what I was talking about. [:D]

I've been working in and around London for the past five years now. I love it, apart from the sunny weather!
Posted by: brenthunter2005 18 years ago
Fifth Degree Brown Belt
0
Not fully understanding, so lets make sure I understand properly.
Are you trying to retrieve a list of the NTFS permissions on each of the profile folders in "C:\Documents and Settings\" ?
Posted by: linstead 18 years ago
Blue Belt
0
yeah that what i want
Posted by: brenthunter2005 18 years ago
Fifth Degree Brown Belt
0
Wow. That was fun! [:@] NOT!!! Though, I did learn something myself! Cheers linstead!

Just copy the code into notepad, and save it with .vbs extension. Its probably best to run this using cscript, rather than just double-clicking on the file.

eg: cscript.exe filename.vbs




On Error Resume Next

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Documents and Settings")
Set objProfileFolders = objFolder.SubFolders

For Each Folder In objProfileFolders
strResults = "Folder: " & Folder.path & VBCRLF
Set wmiFileSecSetting = GetObject("winmgmts:Win32_LogicalFileSecuritySetting.path='" & lcase(Replace(Folder.path,"\","\\")) & "'")
RetVal = wmiFileSecSetting.GetSecurityDescriptor(wmiSecurityDescriptor)
If Err <> 0 Then
WScript.Echo "GetSecurityDescriptor failed" & VBCRLF & Err.Number & VBCRLF & Err.Description
WScript.Quit
End If

' Retrieve the DACL array of Win32_ACE objects.
DACL = wmiSecurityDescriptor.DACL
For each wmiAce in DACL
Set Trustee = wmiAce.Trustee
strReadAccessMask = ReadBitsInAccessMask(wmiAce.AccessMask)
If strReadAccessMask <> "NTFS Access Rights:" Then
strResults = strResults & VBCRLF & "Trustee Domain: " & Trustee.Domain & VBCRLF
strResults = strResults & "Trustee Name: " & Trustee.Name & VBCRLF
strResults = strResults & strReadAccessMask & VBCRLF & VBCRLF
End If
Next
wscript.echo strResults
Next



Function ReadBitsInAccessMask(AccessMask)
Const NTFS_SYNCHRONIZE = &H100000
Const NTFS_WRITE_OWNER = &H80000
Const NTFS_WRITE_DAC = &H40000
Const NTFS_READ_CONTROL= &H20000
Const NTFS_DELETE = &H10000
Const NTFS_FILE_WRITE_A= &H100
Const NTFS_FILE_READ_A = &H80
Const NTFS_FILE_DELETE_C= &H40
Const NTFS_FILE_TRAVERSE= &H20
Const NTFS_FILE_WRITE_EA= &H10
Const NTFS_FILE_READ_EA= &H8
Const NTFS_FILE_ADD_SUBDIR= &H4
Const NTFS_FILE_ADD_FILE= &H1
Const NTFS_FILE_LIST_DIR= &H0
strAccessMaskResults = strAccessMaskResults & "NTFS Access Rights:"
If (AccessMask And NTFS_SYNCHRONIZE) Then _
strAccessMaskResults = strAccessMaskResults & VBCRLF & vbTab & "-SYNC."
If (AccessMask And NTFS_WRITE_OWNER) Then _
strAccessMaskResults = strAccessMaskResults & VBCRLF & vbTab & "-WRITE_OWNER."
If (AccessMask And NTFS_WRITE_DAC) Then _
strAccessMaskResults = strAccessMaskResults & VBCRLF & vbTab & "-WRITE_DAC."
If (AccessMask And NTFS_READ_CONTROL) Then _
strAccessMaskResults = strAccessMaskResults & VBCRLF & vbTab & "-READ_CONTROL."
If (AccessMask And NTFS_DELETE) Then _
strAccessMaskResults = strAccessMaskResults & VBCRLF & vbTab & "-DELETE."
If (AccessMask And NTFS_FILE_WRITE_A) Then _
strAccessMaskResults = strAccessMaskResults & VBCRLF & vbTab & "-WRITE_ATTRIBUTES."
If (AccessMask And NTFS_FILE_READ_A) Then _
strAccessMaskResults = strAccessMaskResults & VBCRLF & vbTab & "-READ_ATTRIBUTES."
If (AccessMask And NTFS_FILE_DELETE_C) Then _
strAccessMaskResults = strAccessMaskResults & VBCRLF & vbTab & "-DELETE_CHILD."
If (AccessMask And NTFS_FILE_TRAVERSE) Then _
strAccessMaskResults = strAccessMaskResults & VBCRLF & vbTab & "-TRAVERSE_DIRECTORY."
If (AccessMask And NTFS_FILE_WRITE_EA) Then _
strAccessMaskResults = strAccessMaskResults & VBCRLF & vbTab & "-WRITE_EXTENDED_ATTRIBUTES."
If (AccessMask And NTFS_FILE_READ_EA) Then _
strAccessMaskResults = strAccessMaskResults & VBCRLF & vbTab & "-READ_EXTENDED_ATTRIBUTES."
If (AccessMask And NTFS_FILE_ADD_SUBDIR) Then _
strAccessMaskResults = strAccessMaskResults & VBCRLF & vbTab & "-ADD_SUBDIRECTORY."
If (AccessMask And NTFS_FILE_ADD_FILE) Then _
strAccessMaskResults = strAccessMaskResults & VBCRLF & vbTab & "-ADD_FILE."
If (AccessMask And NTFS_FILE_LIST_DIR) Then _
strAccessMaskResults = strAccessMaskResults & VBCRLF & vbTab & "-LIST_DIRECTORY."
ReadBitsInAccessMask = strAccessMaskResults
End Function
Posted by: brenthunter2005 18 years ago
Fifth Degree Brown Belt
0
PS: If you like the script and it works for you, then please rate my post.
Posted by: linstead 18 years ago
Blue Belt
0
out of 10 i would say 9

very good work,

what city do you work in?
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ