tags:

views:

91

answers:

2

I have been using Process.Start to launch executables (.exe) files. Now I need to execute a .pl file with some arguments. can I still use Process.Start or I need a different approach?

EDIT :- I am having to mark this question unanswered as I am getting the following error when I try to call the perl file from the CSharp code:- (When I call the same from the commandline with the same path and parameters, It works fine)

System.ApplicationException: StartProcess Failed System.ComponentModel.Win32Exception: The specified executable is not a valid application for this OS platform)

Please note that when I try to call an .exe file from my C# code, I dont see the above error.

EDIT:- Checking the following link now:- http://stackoverflow.com/questions/649993/how-do-i-call-perl-script-in-c-application It seems that the ProcessStartInfo constructor has two parameters - fileName and the arguments. You should set Perl.exe as the fileName and the "argument" would be your perl file (.pl) with other arguments It accepts. Checking now....

+1  A: 

You certainly can :) you can also pass it arguments by adding them after the file name in

Process.Start(file.pl args1 args 2);

It will load the file with your default application for .pl files, the other option is to specify the software then pass your file as a parameter providing you have the right software to handle the file it should be fine

Process.Start() can be pointed at any file and it will be opened using the default software or that which you specify, it need not be an executable.

Yoda
That is a great news for me at least. :-) Will give this a try. have you already tried this ever?
ydobonmai
Tried and tested :)
Yoda
Thank you for the help, Yoda.
ydobonmai
No problem thanks for the accept :)
Yoda
Yoda, please see my latest edit.
ydobonmai
+1  A: 

Yes you can, Process.Start() takes a string parameter, what you pass for this parameter does exactly the same thing it would do if you entered the same string in the windows start -> run dialog.

Ben Robinson