How to pass parameters to a batch file using c#

Viewed 24595

I have a console file, which takes 6 arguments

enter image description here

To run this exe, I create one batch file,

enter image description here

Now, I need to send this parameter to the batch file from my one Windows application. This is the code:

         string consolepath = @"E:\SqlBackup_Programs\console-backup\Backup_Console_App";
            string Pc = "VARUN-PC";
            string database = "Smart_Tracker";
            string UserName = "sa";
            string Password = "admin@12";
            string bacPath = @"D:\TEST";

            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            proc.StartInfo.FileName = System.Configuration.ConfigurationManager.AppSettings["BATCH_FULLBACKUP"].ToString().Trim();
            proc.StartInfo.Arguments = String.Format(consolepath,Pc,database,UserName,Password,"F",bacPath);
            //set the rest of the process settings
            proc.Start();

But its not working. I tried to change my Batch file like,

@echo off %1 %2 %3 %4 %5 %6 %7

@echo off

but that didn't work either.

Error Image:

2 Answers
Related