Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Passing Parameters to Process File

Posted on 2006-12-01
5
Medium Priority
?
223 Views
Last Modified: 2010-04-16
Hi,

I am making application in C#, Windows Application.

I have to call .Net2003 application by sending some parameters

I am doing as below, but I am not able open my application when I send the parameter. But If I send the parameters it says  that

The system cannot find the file specified

I have to pass the below string to the Process

string strIs =" /strsiteurl="+strDestinationURL+" /strsitename="+siteDetails[0]+" /strsitecode="+siteDetails[0]+" /strsitelanguage="+siteDetails[3]+" /strconn="+new DbConnection().strSourceCon+" /strxmlPath="+ConfigurationSettings.AppSettings["SiteXMLPath"].ToString();


try
{
      System.Diagnostics.Process FProcess =
          new System.Diagnostics.Process();
      FProcess.StartInfo.FileName = Application.StartupPath + @"\Decrypt\vb_passwordDcrypt.exe" + strIs;
      
      /*
            But if I uncomment this line then I am able to open my application
      */
      
      //FProcess.StartInfo.FileName = Application.StartupPath + @"\Decrypt\vb_passwordDcrypt.exe";
      FProcess.Start();
      FProcess,pa
      FProcess.SynchronizingObject = this;
      FProcess.Exited += new System.EventHandler(this.FProcess_Exited);
}
catch (Exception ex)
{
      string str = ex.Message.ToString();
}    



From quick watch when I see the text in

Application.StartupPath + @"\Decrypt\vb_passwordDcrypt.exe" + strIs

I get

"C:\\vb\\DotNet2005\\EnetDatabaseMigration\\EnetDatabaseMigration\\bin\\Debug\\Decrypt\\vb_passwordDcrypt.exe /strsiteurl=www.visitbritain.gr /strsitename=el-GR /strsitecode=el-GR /strsitelanguage=Greek /strconn=Data Source=B025765;Initial Catalog=ENET_20NOV_NEW;User Id=sa;Password=sa; connection timeout=230 /strxmlPath=C:\\vb\\DotNet2005\\EnetDatabaseMigration\\EnetDatabaseMigration\\SiteMapping.xml"

Can anyone help me that how to send parameters to this process

Many Thanks
0
Comment
Question by:dinesh_bali
  • 3
5 Comments
 
LVL 27

Expert Comment

by:Chinmay Patel
ID: 18052483
Hi There,

You'll need to en-quote the string you want to send as a parameter try to use @ when you assign value to strIs.

Thanks,
Chinmay
0
 

Author Comment

by:dinesh_bali
ID: 18052485
Can you please correct my code
0
 

Author Comment

by:dinesh_bali
ID: 18052506
I tried changing the line

FProcess.StartInfo.FileName = Application.StartupPath + @"\Decrypt\vb_passwordDcrypt.exe"+ " "+@""+strIs;

still the same error
0
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 2000 total points
ID: 18053034
Hi, you send your application parameters by using the Process.StartInfo.Arguments property not with the FileName property:

      string strIs =" /strsiteurl="+strDestinationURL+" /strsitename="+siteDetails[0]+" /strsitecode="+siteDetails[0]+" /strsitelanguage="+siteDetails[3]+" /strconn="+new DbConnection().strSourceCon+" /strxmlPath="+ConfigurationSettings.AppSettings["SiteXMLPath"].ToString();

      try
      {
            System.Diagnostics.Process FProcess = new System.Diagnostics.Process();
            FProcess.StartInfo.FileName = Application.StartupPath + @"\Decrypt\vb_passwordDcrypt.exe";
            FProcess.StartInfo.Arguments = strIs;
            FProcess.Start();

            FProcess.SynchronizingObject = this;
            FProcess.Exited += new System.EventHandler(this.FProcess_Exited);
      }
      catch (Exception ex)
      {
            //...
      }  
0
 

Author Comment

by:dinesh_bali
ID: 18067828
Many Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question