Solved

Shell command in Visual Basic 2008 (Running cacls commands)

Posted on 2008-10-09
3
3,069 Views
Last Modified: 2012-06-22
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?
0
Comment
Question by:inbisit
  • 2
3 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 22685067
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
 

Author Comment

by:inbisit
ID: 22685285
Hi,

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

Thanks.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 22685376
Following article provides all the information you need.
http://www.thescarms.com/dotnet/Process.aspx
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question