Solved

Passing Parameters to Process File

Posted on 2006-12-01
5
209 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
Comment Utility
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
Comment Utility
Can you please correct my code
0
 

Author Comment

by:dinesh_bali
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
Many Thanks
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now