Helllp with CACLS in VB.NET!

S

Support

in VB.NET, I am trying to assign Group rights to a network file. I am
successfull at impersonating a domain account with rights but the following
code is failing, ie, nothing happens at the file level.

MyProcessString = "cacls.exe """ + ICopyTo + """ /E /G """ + ICopyRights +
""":R"
System.Diagnostics.Process.Start(MyProcessString)
msgbox(MyProcessString)
the MyProcessString MsgBox shows: cacls.exe
"\\main\documents\filename.txt" /E /G "DOMAIN\group name":R
cacls does work with group names and I can get this code to run as a batch
file under the impersonation runas account just fine

I have also tried:


p.StartInfo.FileName = "cacls.exe"
p.StartInfo.Arguments = MyProcess '"" + ICopyTo + """ /E /G """ +
ICopyRights + """:R"
p.StartInfo.Arguments = ICopyTo + " /E /G " + ICopyRights + ":R"
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.UseShellExecute = False
p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized
p.StartInfo.CreateNoWindow = True
p.Start()
p.WaitForExit()
ProcessOutput = p.ExitCode.ToString()

but I get a variety of error numbers like error 5, etc.. and I do not know
where I can find error code interpretations and this does not work either
....

Any suggestions !

Thanks

Terry
 
S

Support

New information: I modified my code to see what is happening:
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized
myProcess.StartInfo.RedirectStandardOutput = False
myProcess.StartInfo.CreateNoWindow = False

and type my CACLS code manually and I get an Access is denied - error number
5
so I guess the problem is that when I shell out within my impersonation
area - that the rights are not transfered ... hmmm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top