I want to execute a command to query DHCP Server. For that purpose I have written some code in perl. Now when I execute that perl file in command prompt using c# I get following errer "The specified executable is not a valid Win32 application." I have pasted the code below. Can anybody please suggest what could be the possible reason of this error message.

System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo.WorkingDirectory = "c:\\Windows";
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.FileName = "lease_query.pl";
            p.StartInfo.Arguments = "perl lease_query.pl " + ipAddress;

            p.StartInfo.CreateNoWindow = true;



You might need to specify the full path in p.StartInfo.FileName = "lease_query.pl"; .
E.G. p.StartInfo.FileName = "c:\\MyApps\\lease_query.pl";

Actually I think the FileName and Arguments mixed up because the final command yours is running would look like
C:\>lease_query.pl perl lease_query.pl
and lease_query.pl is not an executable.

so i think it should be.

p.StartInfo.FileName = "perl";
p.StartInfo.Arguments = "lease_query.pl " + ipAddress;

Edited 6 Years Ago by =OTS=G-Man: n/a

I didn't see that. Well spotted.
This question has already been answered. Start a new discussion instead.