Solved

Passing Parameters to Process File

Posted on 2006-12-01
5
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

734 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