I'm working to a website with a form where the user can upload a file and i developed a method that performs a realtime scan of the files uploaded on the website (.net application in c#).
I have a problem, i get always 0 as exitcode and i fear that the string i specify as Arguments to the process object is wrong and that the file scan is not executed at all.
Process p = new Process();
string exefileName = "\"C:\\Program Files (x86)\\Symantec\\Symantec Endpoint Protection\\DoScan.exe\"";
ProcessStartInfo processInfo = new ProcessStartInfo();
processInfo.FileName = exefileName;
processInfo.Arguments = "/c \"C:\\Program Files (x86)\\Symantec\\Symantec Endpoint Protection\\DoScan.exe\" /ScanFile \"E:\\WWW\\myfolder\\myfile.com\"";
p.StartInfo = processInfo;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
p.WaitForExit(5000); //wait
int exitCode = -1;
if (p.WaitForExit(5000))
{
exitCode = p.ExitCode;
}
Can you help me please?
Thanks
Original Message:
Sent: 10-03-2019 09:23 AM
From: Unknown User
Subject: How to use DoScan.exe to start a Symantec Endpoint Protection (SEP) client scan from a command-line in Asp.net c#
Hi Harpreet,
Most of the time I user powershell, but if you are looking for any application launch ( .exe ) with arguments , this is the blue print
using System.Diagnostics;// Prepare the process to runProcessStartInfo start = new ProcessStartInfo();// Enter in the command line arguments, everything you would enter after the executable name itselfstart.Arguments = arguments; // Enter the executable to run, including the complete pathstart.FileName = ExeName;// Do you want to show a console window?start.WindowStyle = ProcessWindowStyle.Hidden;start.CreateNoWindow = true;int exitCode;// Run the external process & wait for it to finishusing (Process proc = Process.Start(start)){ proc.WaitForExit(); // Retrieve the app's exit code exitCode = proc.ExitCode;}https://stackoverflow.com/questions/240171/launching-an-application-exe-from-c