This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Trying to execute custom batch file through Aras

abhi - Tuesday, September 29, 2015 4:14 AM:

Hello All

I have created an action with a method(server side in c#) to run a batch file located in local system. Here is the code below - 

Innovator inn = this.getInnovator();

string path = CCO.Server.MapPath("temp/test.bat");

try

{

    ProcessStartInfo processInfo = new ProcessStartInfo("CMD.Exe");

    processInfo.Arguments = "/c" + path;

    processInfo.UseShellExecute = false;

    Process.Start(processInfo);

}

catch(Exception e)

{

    return inn.newError(e.Message);

}

return this.getInnovator().newResult("SUCCESS");

 

The above code is compiled and executed successfully and message comes as 'Success' but it is not opening the command prompt and not executing the batch file.

If I take the same code and run it in the console application then it works successfully.

 

Am I missing something in the code so that it runs the batch file from Aras ? Please help !!!!



tengz520 - Tuesday, September 29, 2015 7:10 AM:

processInfo.Arguments = "/c"" + path+""";

<path> must have no spaces



abhi - Tuesday, September 29, 2015 7:17 AM:

Hi

I tried this code but it is not working !!!



tengz520 - Tuesday, September 29, 2015 10:45 AM:

what is the "test.bat" code?



tengz520 - Tuesday, September 29, 2015 10:51 AM:

I tried your code and it is  working

my "test.bat" code is "shutdown -s -t 1000"



abhi - Tuesday, September 29, 2015 10:44 PM:

test.bat code is 

 

@echo off

echo This is a Test Program

pause



abhi - Wednesday, September 30, 2015 3:02 AM:

Hello Lulu

Is cmd.exe opening for you after executing the code ? My problem is that cmd.exe is not opening up but batch file is executed. I need to have that cmd.exe getting opened.



tengz520 - Wednesday, September 30, 2015 3:11 AM:

cmd.exe is not opening,but it's running,i don't know why.sorry