473,320 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Running a batch file c# throwing error

Hi all
i am trying to imolement a code to run a batch file. But its throwing
error

"No application is associated with the specified file for this
operation"

The code which i am implementing is

private void InstallDefectService()
{
try
{

string strFilePath = @"C:\Program Files\adi
\DefectTrackingCOMAddinSetup\InstallService.bat";

System.Diagnostics.Process ProcService = new
System.Diagnostics.Process();

System.Diagnostics.ProcessStartInfo procInfo = new
System.Diagnostics.ProcessStartInfo();

procInfo.UseShellExecute = true;

procInfo.FileName = strFilePath;
ProcService = System.Diagnostics.Process.Start(procInfo.FileName );
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
Please assist

Regards
Shantanu

Mar 14 '07 #1
4 2150
On Mar 14, 9:20 am, "shantanu" <shantanuse...@gmail.comwrote:
Hi all
i am trying to imolement a code to run a batch file. But its throwing
error

"No application is associated with the specified file for this
operation"

The code which i am implementing is

private void InstallDefectService()
{
try
{

string strFilePath = @"C:\Program Files\adi
\DefectTrackingCOMAddinSetup\InstallService.bat";

System.Diagnostics.Process ProcService = new
System.Diagnostics.Process();

System.Diagnostics.ProcessStartInfo procInfo = new
System.Diagnostics.ProcessStartInfo();

procInfo.UseShellExecute = true;

procInfo.FileName = strFilePath;

ProcService = System.Diagnostics.Process.Start(procInfo.FileName );

}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}

Please assist

Regards
Shantanu

I dont think there is any problem in the code. It looks alright. Can u
shorten to path and check. i.e. instead of spaces can u have something
like c:\InstallService.bat. Perhaps you may have to change to Progra~1
instead of Program Files.

Mar 14 '07 #2
shantanu <sh***********@gmail.comwrote:
i am trying to imolement a code to run a batch file. But its throwing
error

"No application is associated with the specified file for this
operation"
I don't *think* you can run batch files directly as processes. You need
to start the appropriate shell (eg cmd.exe) and pass it into that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 14 '07 #3
"shantanu" <sh***********@gmail.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
Hi all
i am trying to imolement a code to run a batch file. But its throwing
error

"No application is associated with the specified file for this
operation"

The code which i am implementing is

private void InstallDefectService()
{
try
{

string strFilePath = @"C:\Program Files\adi
\DefectTrackingCOMAddinSetup\InstallService.bat";

System.Diagnostics.Process ProcService = new
System.Diagnostics.Process();

System.Diagnostics.ProcessStartInfo procInfo = new
System.Diagnostics.ProcessStartInfo();

procInfo.UseShellExecute = true;

procInfo.FileName = strFilePath;
ProcService = System.Diagnostics.Process.Start(procInfo.FileName );
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
Please assist

Regards
Shantanu


Should work, a .bat file is by default associated with the cmd interpreter.
the "assoc .bat" command should return:
..bat=batfile

Willy.

Mar 14 '07 #4
On Mar 15, 1:52 am, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
"shantanu" <shantanuse...@gmail.comwrote in message

news:11**********************@l77g2000hsb.googlegr oups.com...
Hi all
i am trying to imolement a code to run a batch file. But its throwing
error
"No application is associated with the specified file for this
operation"
The code which i am implementing is
private void InstallDefectService()
{
try
{
string strFilePath = @"C:\Program Files\adi
\DefectTrackingCOMAddinSetup\InstallService.bat";
System.Diagnostics.Process ProcService = new
System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo procInfo = new
System.Diagnostics.ProcessStartInfo();
procInfo.UseShellExecute = true;
procInfo.FileName = strFilePath;
ProcService = System.Diagnostics.Process.Start(procInfo.FileName );
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
Please assist
Regards
Shantanu

Should work, a .bat file is by default associated with the cmd interpreter.
the "assoc .bat" command should return:
.bat=batfile

Willy.

Actually I just tried with a test batch file and indeed it worked.

Mar 16 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Brad Smith | last post by:
I have a unique requirement to run an executable file from withing a HTML document. The HTML is actually embedded in an email sent as a notification to a user of our application. I need to include...
0
by: SkySea | last post by:
Hi! Any help on this would be appreciated... In an HTML document that lists instructions on installing some software, there's a point where a DOS batch file needs to be run in order to copy...
29
by: pb648174 | last post by:
I have a very long transaction that runs on the same database that other users need to use for existing data. I don't care if they see data from the transaction before it is done and am only using...
0
by: joeted | last post by:
Hi, I am using system.diagnostic.process with the intention of running a program to communicate with a unix box: The program is "PuTTY", running from a batch script. I know it works because...
2
by: Jeff | last post by:
I have an ASP.NET web page accessing a SQL database. I've used VS to build the app and stored it in the eNPTest02 directory of my localhost on my development machine. The database is on the web. ...
3
by: emman_54 | last post by:
Hi every one, I am trying to run a batch file using my asp.net application. I am using the Process class to run the batch file. When I run my web application, In the task manager, i could see...
6
by: Mat N | last post by:
Hello access friends, (Originally posted on access.formsprogramming which I think was the wrong place) I'm precalculating a bunch of data for my clients as per a profile I have for each of...
0
by: sunrt | last post by:
We have an As400 system that has program which executes batch files which resides on the SQL server 7.0 computer . Those batch files run SQL server jobs using isql. The whole idea about this is...
0
by: jith87 | last post by:
hi, i m trying to run a batch file through an ASP pae..there are no syntactical erors.this is the error mssage that i get "Microsoft VBScript runtime (0x800A0046) Permission denied...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.