Set folder permissions from C # - convert CreateObject ("Wscript.Shell") from vb to C #

I would like to know how to convert this vb script to C #

Dim strFolder As String
Dim objShell As Object

strFolder = "C:\zz"

Set objShell = CreateObject("Wscript.Shell")

objShell.Run "%COMSPEC% /c Echo Y| cacls " & _
                 strFolder & _
                 " /t /c /g everyone:F ", 2, True

      

What I am trying to do is set permissions to "Everyone" in the newly created folder on the users drive C: \.

I am using Visual Studio, .Net 1.1

Thank. Ian

+1


source to share


3 answers


Unfortunately, it is not possible to upgrade - I work for a large company, so that would mean upgrading loads of people - which will be the mission ...

But - creating a process!



System.Diagnostics.Process meProc = System.Diagnostics.Process.Start ("cmd.exe", " /c echo y| cacls C:\\zzz /t /c /g everyone:F");

      

Thank you both for your help.

+1


source


Is it possible to upgrade to a newer version? .NET 2.0 has introduced classes into the System.Security.AccessControl namespace to handle this. If this is really not possible and you only have one command to execute, you can create a Process and just execute cacls

in it.



0


source


This also uses the Microsoft.Win32.Security library ...

I don't have a SecuredObject

SecuredObject sec = new SecuredObject("C:\\", SecuredObjectType.FileObject);

      

0


source







All Articles