Hi
I have a .net framework 4.7 project (dll) in which i am calling an exe (.net framework) as follows:
Process visProc = Process.GetCurrentProcess();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "C:\program files\Test.exe"
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.UseShellExecute = true;
startInfo.Verb = "runas";
startInfo.Arguments = "Hello";
try
{
Process exeProcess = Process.Start(startInfo);
exeProcess.WaitForExit();
}
catch (Exception e)
{
}
The above code when i am invoking through UI, the process.start() invoking my Test.exe project perfectly and getting all the output as expected. But when the same code is executed through schedule workflow (batch job), the Process.Start throwing an exception. UAC is high on my machine..
Not sure whats wrong in the code code for schedule workflows.
Message in event viewer as follows:
System error number 0x5: Access is denied.
Standard-ouput file could not be returned to backup destination.
File removed.
System error number 0x5: Access is denied.
Process exit status: -532462766.
What I have tried:
The reason why i should run my exe as admin (verb = "runas") is i have to create a folder in C:\Program Files\softwares run time. so the code is
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "C:\program files\Test.exe"
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.UseShellExecute = true;
startInfo.Verb = "runas";
startInfo.Arguments = "Hello";