Solved

Passing Parameters to Process File

Posted on 2006-12-01
5
212 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

713 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