By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,890 Members | 1,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,890 IT Pros & Developers. It's quick & easy.

How do I shell the following command line or process.start it (very different command!)

P: n/a
G'Day all,
I cant for the God in me work out how to execute the following command
line in vb.net: (watch for the word wrapping also)

Sub(ByVal username As String)

Shell("ECHO Y| cacls h:\finance\" & username & "\" & "+Common /G " &
username & ":R", AppWinStyle.Hide, True)

End Sub

Now if I was to paste that snippet into a cmd prompt and run it it
will work no worries as it does also from a .bat file.

The ECHO Y| is there because if you execute the command without it it
will ask for a <y/N> to confirm, obviously stalling the process and
not completing it.

So what are some alternatives or what am I doing wrong?

Cheers

Dave. :-)
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
David Eadie wrote:
G'Day all,
I cant for the God in me work out how to execute the following command
line in vb.net: (watch for the word wrapping also)

Sub(ByVal username As String)

Shell("ECHO Y| cacls h:\finance\" & username & "\" & "+Common /G " &
username & ":R", AppWinStyle.Hide, True)

End Sub


I think the problem you're having is that ECHO is not an executable program,
but rather is a function provided by the command prompt itself. This means
you can't directly Shell it as the system doesn't know what it is.

What you can do however is shell the command prompt itself and get it to
execute the ECHO automatically. Try this:

Shell("cmd.exe /C ECHO Y| cacls h:\finance\" & username & "\" & "+Common /G
" & username & ":R", AppWinStyle.Hide, True)

(Again, watch for the wrapping).

The /C switch for the cmd.exe application tells it to execute the statement
provided and then immediately close (for more information, launch a command
prompt and then type "cmd /?" into it).

Hopefully this will do what you want -- but be aware that on Win95/98/Me,
the command processer is actually "command.com" (I think), rather than
"cmd.exe". I don't have access to a Win9x machine at the moment so I don't
know if it supports the same command switch, you'll need to investigate if
it's relevant to what you're doing.

Hope that helps,

--

(O)enone

Nov 21 '05 #2

P: n/a
Ahh great help! Yeah its only for server 2003, nothing else.
Ill give it a go later on when im back at the Dev machine and see how I
go.
Cheers mate

David

Nov 21 '05 #3

P: n/a
Great works a charm!!
Thanks mate!!!

Dave.

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.