Link to home
Start Free TrialLog in
Avatar of dinesh_bali
dinesh_bali

asked on

Passing Parameters to Process File

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
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

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
Avatar of dinesh_bali
dinesh_bali

ASKER

Can you please correct my code
I tried changing the line

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

still the same error
ASKER CERTIFIED SOLUTION
Avatar of Ravi Singh
Ravi Singh
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Many Thanks