Shell command in Visual Basic 2008 (Running cacls commands)

I'm trying to use the SHELL command in Visual Basic to set folder security on a remote drive.

I'm using..
Shell("cacls ""\\ukpreflr1\preston1$\" & PNumber.Text & "\01 Quotations"" /E /P Domain\Proj-" & PNumber & ":R")
This command is repeated to set the security on another 30 folders...

This works fine, however, i am asked "are you sure" on several of the folders.. i do i pass a "Y" to the shell?  In Vbscript i could use "echo Y|cacls..." but this won't work in Visual for some reason... Anybody got any idea's?


Secondly, whilst each command is processed, the shell window sits on top of the VB Application, how can i stop this so that the status i created on the Application can be seen?
inbisitAsked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
Following article provides all the information you need.
http://www.thescarms.com/dotnet/Process.aspx
0
 
CodeCruiserCommented:
Hi,
You can use the Process class static methods to run the shell command and start the command window invisibly. Then you can probably use the Sendkeys function to send Y to the process.
0
 
inbisitAuthor Commented:
Hi,

I'm a novice Vb user... would you happen to have an example?

Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.