How to run exe from c# dll which is called from asp - c#

I have create c# dll which is contained in web directory of the product. This dll contain a function which accept some parameters and call a exe (phantomjs.exe) with accepted parameters.I also have write some logging code for file writing in this function. Now I call this dll from asp classic code. Then I found that log maintain by this dll but work of phantomjs.exe does not occur. While when I call this dll from console application then phantomjs.exe works.
I use below code to call the exe
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.FileName = pDirectory + "\\res\\bin\\phantomjs.exe";
p.StartInfo.Arguments = arguments;
p.Start();
p.WaitForExit();
Please tell me will there be a need to sign this phantomjs.exe to run in webdirectory or any thing else.

Related

System cannot find file specified

So we need to execute a exe in our .net API, and this exe is built at the same time as the API itself in our pipelines.
The exe is present in the exact same directory as our .NET API exe and ddl files.
I used the below code to try and trigger the exe:
var process = new System.Diagnostics.Process();
process.StartInfo.FileName = "customProgram.exe";
process.StartInfo.Arguments = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
process.Start();
process.WaitForExit();
This throws an error:
An error occurred trying to start process 'customProgram.exe' with working directory '/app'. No such file or directory
Try to specify the full path to the file.
For example like here:
Process.Start(#"C:\Program Files\Google\Chrome\Application\chrome");

Is it Possible to Run a C# project using Another c# project

is it possible to run a C# project Already build using another project? there is any way to invoke the c# execution using a c# Code.
In here I need to execute the Already Compile Project inside a another project.
You can run an exe using Process.Start
ProcessStartInfo ps = new ProcessStartInfo("YourExecutable.exe", "any arguments");
ps.WindowStyle = ProcessWindowStyle.Hidden; // or exclude this line to show it
ps.CreateNoWindow = true; // and this line
ps.UseShellExecute = false;
Process process = new Process();
process.StartInfo = ps;
process.Start();
There are additional ways to get the output of your process for displaying or logging but that is easily searchable.

Guidance for invoking .jar file through asp.net code

ProcessStartInfo psi = new ProcessStartInfo("java.exe", " -jar \"C:\\craFVUsubsreg-lite_APY.jar\"");
psi.UseShellExecute = false;
Process p = new Process();
p.StartInfo = psi;
p.Start();
I want to invoke the utility tool, which is of java.jar file within the "c#" [mvc] application and it is work fine when i run the application through code. However after i published the application and then i try to invoke the same jar file it is not responding or i can say it is not working.
Above is the process code which i'm using to invoke the jar file. Even the user permission i have setted to full control mode.
Kindly guide me, where i am wrong, or is their any way to directly invoke the java.jar file without converting to java.exe.

How to run batch file using IronPython

I have newly started working with IronPython. I have a batch file with some commands.
This file needs to be executed from IronPython. Can it be accomplished?
I was trying to add .net reference but couldn't create object for class Process. Is the approach correct?
import clr
clr.AddReference("System.Diagnostics")
from System.Diagnostics import Process
System.Diagnostics is a namespace.
clr.AddReference accepts System.Reflection.Assembly objects and/or assembly names., e.g.:
clr.AddReference("System.Windows.Forms")
The Process class is in assembly "System.dll" so you don't have to add anything.
Try this:
from System.Diagnostics import Process
p = Process()
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = False
p.StartInfo.FileName = 'C:\\ping.bat'
p.Start()
p.WaitForExit()
print(p.ExitCode)

can i install the .exe file without user interaction

Can I install the .exe file without user interaction (means without click on the next or install button)
I have write the code to call .exe file but, it doesn't install silently in background.
Process p = new Process();
p.StartInfo.FileName = #"C:\Downloads\teamViewer.exe";
p.StartInfo.Arguments = "/S";
p.Start();
p.StartInfo.CreateNoWindow = true;
p.WaitForExit();
Why exe not run in background, with this code?
You can do a silent install with the EXE you download from the website.
You have to use the one that it extracts into your
%temp%\TeamViewer\VersionX\TeamViewer_.exe
As of version 7 %temp%\TeamViewer\Version7\TeamViewer_.exe. This one supports the /S argument, but there is another problem : UAC confirmation dialog and as far as I know you can't bypass this with code (unless your app is already running with admin privileges. You can use an application manifest for that).

Categories

Resources