Saturday, January 8, 2011

NTFS Permission using Command Prompt and .NET Framework Class Library

To provide NTFS Permission to any file using the Command Prompt, here is the command

CACLS "C:\test.bat" /e /p EveryOne:f

The above command gives "Full" permission to the file "test.bat" for "EveryOne" user

For more info, visit http://technet.microsoft.com/en-us/library/bb490872.aspx


VB.NET code for the same,

Imports System.IO

Imports System.Security.AccessControl

Dim fSecurity As FileSecurity

fSecurity = File.GetAccessControl(fileName)

fSecurity.AddAccessRule(New FileSystemAccessRule("EveryOne", FileSystemRights.Write, AccessControlType.Allow))

File.SetAccessControl(fileName, fSecurity)

No comments:

Post a Comment

AZ-104

Microsoft Azure is huge and it has hundreds of services underneath its umbrella It's actually going to be quite difficult to comprehend ...