I can create single exe of my winform application by installing costura.fody. This helps me to bind all references (dll fiies) that I used in the project to a single exe file.
Now I want to execute a batch file when user clicks on a button on my winform app. I can achieve it by below code. But the full path of batch file is hardcoded here.
Can I embed this batch file to my single exe? If then what should be the path of this batch file?
private void bt_uninstall_Click(object sender, EventArgs e)
{
Process proc = null;
try
{
string batDir = string.Format(@"C:\Users\Abram\Documents\Visual Studio 2017\Projects\TestApp\TestApp\DriverRegistration");
proc = new Process();
proc.StartInfo.WorkingDirectory = batDir;
proc.StartInfo.FileName = "runDriver.bat";
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.Verb = "runas";
proc.Start();
proc.WaitForExit();
MessageBox.Show("Bat file executed !!");
}
catch (Exception ex)
{
MessageBox.Show(ex.StackTrace.ToString());
}
}