Greetings,
I have been through the forum and have seen much of the information in the UDF. Unfortunately, my brain is just not successfully connecting the dots. I need to be able to do the following:
1. Get permissions to file
2. Determine if permissions are within specs
- users permission must be "No Access"
- username permission must be "No Access"
3. If permission is not "No Access", the username, machinename will be copied to a text file on the domain server for sysadmin to take action.
We have to be able to determine permissions on a file. No problem there...this is shell we use for the permission check:
Code:
Function Tail($file,optional $lines, optional $skip)
dim $fso, $f,$fs,$i,$all
if not $lines $lines = 1 endif
if not $skip $skip = 0 endif
$fso = CreateObject("Scripting.FileSystemObject")
$f = $fso.GetFile($file)
if @error exit(2) endif
$fs = $f.OpenAsTextStream(1)
if $skip $fs.Skip($skip) endif
$all = split($fs.Read($f.size-$skip),@crlf)
if $lines = -1
redim preserve $all[ubound($all)-1]
$tail = $all
exit(0)
endif
dim $out[$lines]
for $i = ubound($all)-$lines to ubound($all)
$out[$i-(ubound($all)-$lines)] = $all[$i]
next
redim preserve $out[ubound($out)-1]
$tail=$out Exit(0)
endfunction
$file = "c:\perm.txt"
; Start the process ////////////////////////
SHELL "CMD.EXE /C perms /i users c:\winnt\system32\drivers\usbstor.sys > c:\perm.txt"
for each $line in tail($file,-1,42)
shell "cmd.exe /c echo users $line >> c:\perm1.txt"
next
SHELL "CMD.EXE /C perms /i %username% c:\winnt\system32\drivers\usbstor.sys > c:\perm.txt"
for each $line in tail($file,-1,42)
shell "cmd.exe /c echo %username% $line >> c:\perm1.txt"
next
del "c:\perm.txt"
; ///////////////////////
The output file looks like this:
Code:
users perms: R-X----
jechilt perms: #RWXDPOA
I am thinking that the TRIM and SPLIT would allow the check of the permission after the ':' by assigning the permission as a variable and running a loop on it. My problem is my lack of experience to make this happen.
Any suggestion or pointers in the right direction would be most kind.
Kind Regards...