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

D

David Eadie

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. :)
 
O

Oenone

David said:
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,
 
H

hack123

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
 

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