|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How do I shell the following command line or process.start it (very different command!)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. :-) David Eadie wrote:
> G'Day all, I think the problem you're having is that ECHO is not an executable program, > 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 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 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
How to Share Class Properties Across Processes
no indexof-function for collection object available. delete rows from datagrid Finalize and database connection... contradiction in msdn or a misunderstaning from my part ? Open a CSV file What is .NET Redistributable? Deleting 100,000 rows Oledb???? High Speed Graphics Windows Service and application.DoEvents() |
|||||||||||||||||||||||