Home All Groups Group Topic Archive Search About

Writing commands to cmd from VB.Net 2005

Author
7 Nov 2006 10:28 AM
Nettan
Hi everyone. I hope that someone can help me.

I'm trying to start a command prompt from vb.net 2005 with
newProc.Start("cmd.exe"). This works but then I want to write commands to
the process. I have tried

newProc.StartInfo.FileName = "cmd.exe"
newProc.StartInfo.UseShellExecute = False
newProc.StartInfo.redirectStandardInput = True  
newProc.Start()
newProc.StandardInput.WriteLine("cd testmap")

This does'nt work and when I use the redirectStandardInput the cmd-window
disapear.

Author
7 Nov 2006 11:51 AM
Robinson
Show quote Hide quote
"Nettan" <Net***@discussions.microsoft.com> wrote in message
news:8918E3D2-D2B7-4C47-92B1-8E20E3582090@microsoft.com...
> Hi everyone. I hope that someone can help me.
>
> I'm trying to start a command prompt from vb.net 2005 with
> newProc.Start("cmd.exe"). This works but then I want to write commands to
> the process. I have tried
>
> newProc.StartInfo.FileName = "cmd.exe"
> newProc.StartInfo.UseShellExecute = False
> newProc.StartInfo.redirectStandardInput = True
> newProc.Start()
> newProc.StandardInput.WriteLine("cd testmap")
>
> This does'nt work and when I use the redirectStandardInput the cmd-window
> disapear.

Sorry I don't know the specifics of how to code to CMD, but my first thought
was to write out a batch file and execute that instead of redirecting
standard input.
Author
7 Nov 2006 12:27 PM
Nettan
Thanks, I tried with a batch-file instead and it works fine.

Show quoteHide quote
"Robinson" wrote:

> "Nettan" <Net***@discussions.microsoft.com> wrote in message
> news:8918E3D2-D2B7-4C47-92B1-8E20E3582090@microsoft.com...
> > Hi everyone. I hope that someone can help me.
> >
> > I'm trying to start a command prompt from vb.net 2005 with
> > newProc.Start("cmd.exe"). This works but then I want to write commands to
> > the process. I have tried
> >
> > newProc.StartInfo.FileName = "cmd.exe"
> > newProc.StartInfo.UseShellExecute = False
> > newProc.StartInfo.redirectStandardInput = True
> > newProc.Start()
> > newProc.StandardInput.WriteLine("cd testmap")
> >
> > This does'nt work and when I use the redirectStandardInput the cmd-window
> > disapear.
>
> Sorry I don't know the specifics of how to code to CMD, but my first thought
> was to write out a batch file and execute that instead of redirecting
> standard input.
>
>
>