I'd like to know how to convert this vb script to C#
我想知道如何将此vb脚本转换为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'm trying to do is set permissions to "Everyone" on a newly created folder on the users C:\ drive.
我要做的是在用户C:\驱动器上新创建的文件夹上为“Everyone”设置权限。
I'm using Visual Studio, .Net 1.1
我正在使用Visual Studio,.Net 1.1
Thanks. Iain
3 个解决方案
#1
1
It's not possible to upgrade unfortunately - I work for a big company, so would mean updating loads of people - which would be a mission...
不幸的是升级是不可能的 - 我为一家大公司工作,所以意味着要更新大量人员 - 这将是一项使命......
But - creating a process worked!
但是 - 创建一个过程是有效的!
System.Diagnostics.Process meProc = System.Diagnostics.Process.Start ("cmd.exe", " /c echo y| cacls C:\\zzz /t /c /g everyone:F");
Thanks both of you for your help.
谢谢你们的帮助。
#2
0
Is upgrading to a newer version not possible? .NET 2.0 introduced classes in the System.Security.AccessControl namespace to handle this. If it's really not possible and you only have this one command to execute, you may want to create a Process and just execute the cacls
command in it.
升级到新版本是不可能的? .NET 2.0在System.Security.AccessControl命名空间中引入了类来处理这个问题。如果它真的不可能并且您只需要执行这一个命令,那么您可能需要创建一个Process并在其中执行cacls命令。
#3
0
This is also using the "Microsoft.Win32.Security" library...
这也是使用“Microsoft.Win32.Security”库...
I've no SecuredObject
我没有SecuredObject
SecuredObject sec = new SecuredObject("C:\\", SecuredObjectType.FileObject);
#1
1
It's not possible to upgrade unfortunately - I work for a big company, so would mean updating loads of people - which would be a mission...
不幸的是升级是不可能的 - 我为一家大公司工作,所以意味着要更新大量人员 - 这将是一项使命......
But - creating a process worked!
但是 - 创建一个过程是有效的!
System.Diagnostics.Process meProc = System.Diagnostics.Process.Start ("cmd.exe", " /c echo y| cacls C:\\zzz /t /c /g everyone:F");
Thanks both of you for your help.
谢谢你们的帮助。
#2
0
Is upgrading to a newer version not possible? .NET 2.0 introduced classes in the System.Security.AccessControl namespace to handle this. If it's really not possible and you only have this one command to execute, you may want to create a Process and just execute the cacls
command in it.
升级到新版本是不可能的? .NET 2.0在System.Security.AccessControl命名空间中引入了类来处理这个问题。如果它真的不可能并且您只需要执行这一个命令,那么您可能需要创建一个Process并在其中执行cacls命令。
#3
0
This is also using the "Microsoft.Win32.Security" library...
这也是使用“Microsoft.Win32.Security”库...
I've no SecuredObject
我没有SecuredObject
SecuredObject sec = new SecuredObject("C:\\", SecuredObjectType.FileObject);