🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.csharpbuilder.winforms.general
2 messages
2 total messages Started by J.A. Smit Tue, 08 Mar 2005 00:26
Running a batch in the windows shell with parameters.
#25
Author: J.A. Smit
Date: Tue, 08 Mar 2005 00:26
25 lines
1745 bytes
Hi,
well my subject covers the question completely.

How do I run a batch WITH parameters from my C# Windows application.
I can run only the batch without a hitch but when I try to give some
parameters it comes back with an unhandled exception.

The code I use:

private void button1_Click(object sender, System.EventArgs e)
  {
   if ((textBox1.Text!="")&&(textBox2.Text!=""))
   {Process myProcess = new Process();
    string Path="C:\x5cProgram Files\x5cVPN";
    string UserInfo= textBox1.Text+" "+textBox2.Text;
    myProcess.StartInfo.FileName = Path + "\x5cVPN.bat " + UserInfo;
    myProcess.Start();
   }

So I type in two parameters (username+ password) and click a button to start
my batch (witch runs rasdial and creates mappings).
Any tips would be greatly appreciated..

regards
J.A. Smit
Re: Running a batch in the windows shell with parameters.
#21
Author: Marc Rohloff TeamB
Date: Tue, 08 Mar 2005 02:22
23 lines
1981 bytes
On Tue, 8 Mar 2005 01:26:25 +0100, J.A. Smit wrote:

>    {Process myProcess = new Process();
>     string Path="C:\x5cProgram Files\x5cVPN";
>     string UserInfo= textBox1.Text+" "+textBox2.Text;
>     myProcess.StartInfo.FileName = Path + "\x5cVPN.bat " + UserInfo;
>     myProcess.Start();

You need to put the arguments in the Arguments property of the
StartInfo.
ie:
  myProcess.StartInfo.FileName = Path + "\x5cVPN.bat ";
  myProcess.StartInfo.Arguments = UserInfo;


Also there are easier ways (IMO) to set the Path:
   string Path="C:\\Program Files\\VPN";
or
   string Path=@"C:\Program Files\VPN";
   
-- 
Marc Rohloff [TeamB]
marc rohloff -at- myrealbox -dot- com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads