davidlars99
asked on
Modify File Permissions in VB.NET
I'm trying to modify folder's security options and it doesn't work, it works only thru the command prompt with this parameters
cacls.exe c:\dave /t /P ASPNET:f
does anybody have any idea what I am doing wrong...?
Imports System
Imports System.Collections
Public Class FileSecurity
Public Shared Function SetSecurity() As String
Dim _cmdLine As String = "c:\dave /t /P ASPNET:F"
Try
Dim p As System.Diagnostics.Process = New System.Diagnostics.Process
p.StartInfo.FileName = "cacls.exe"
p.StartInfo.Arguments = _cmdLine
p.StartInfo.RedirectStanda rdOutput = True
p.StartInfo.UseShellExecut e = False
p.StartInfo.WindowStyle = Diagnostics.ProcessWindowS tyle.Minim ized
p.StartInfo.CreateNoWindow = True
p.Start()
'Return p.StandardOutput.ReadToEnd .ToString
Catch ex As Exception
Return ex.Message
End Try
End Function
End Class
cacls.exe c:\dave /t /P ASPNET:f
does anybody have any idea what I am doing wrong...?
Imports System
Imports System.Collections
Public Class FileSecurity
Public Shared Function SetSecurity() As String
Dim _cmdLine As String = "c:\dave /t /P ASPNET:F"
Try
Dim p As System.Diagnostics.Process
p.StartInfo.FileName = "cacls.exe"
p.StartInfo.Arguments = _cmdLine
p.StartInfo.RedirectStanda
p.StartInfo.UseShellExecut
p.StartInfo.WindowStyle = Diagnostics.ProcessWindowS
p.StartInfo.CreateNoWindow
p.Start()
'Return p.StandardOutput.ReadToEnd
Catch ex As Exception
Return ex.Message
End Try
End Function
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
no, I'm not getting any error, the page just won't finish loading... if I comment out this line "psi.Arguments = _cmdLine" then I just get same output as you would get from the orginal command prompt window, I have no idea what I'm doing wrong, I am logged in as Admin and ASPNET account belongs to Admin group... frantik... :)
ASKER
I forgot to mention that I doing this from web app
ASKER
I'm going to delete this question unless nobody minds... :)
Please remember to delete this question.
Bob "Cleanup Volunteer"
Bob "Cleanup Volunteer"
ASKER
if anyone is interested I just found the way... :)
Public Shared Function Extractor(ByVal path As String) As String
Dim p As System.Diagnostics.Process = New System.Diagnostics.Process
Try
p.StartInfo.FileName = "CACLS"
p.StartInfo.Arguments = "C:\Inetpub\wwwroot\asp.ne t\mcad\sta temanageme nt /E /P DAVE\IUSR_DAVE:F"
p.StartInfo.RedirectStanda rdInput = True
p.StartInfo.RedirectStanda rdOutput = True
p.StartInfo.UseShellExecut e = False
p.StartInfo.WindowStyle = Diagnostics.ProcessWindowS tyle.Hidde n
p.Start()
p.WaitForExit(1000)
Return p.StandardOutput.ReadToEnd .ToString
Catch ex As Exception
Return ex.Message
Finally
If Not p Is Nothing Then
p.Dispose()
p = Nothing
End If
End Try
End Function
Public Shared Function Extractor(ByVal path As String) As String
Dim p As System.Diagnostics.Process
Try
p.StartInfo.FileName = "CACLS"
p.StartInfo.Arguments = "C:\Inetpub\wwwroot\asp.ne
p.StartInfo.RedirectStanda
p.StartInfo.RedirectStanda
p.StartInfo.UseShellExecut
p.StartInfo.WindowStyle = Diagnostics.ProcessWindowS
p.Start()
p.WaitForExit(1000)
Return p.StandardOutput.ReadToEnd
Catch ex As Exception
Return ex.Message
Finally
If Not p Is Nothing Then
p.Dispose()
p = Nothing
End If
End Try
End Function
ASKER