c# cannot run process(cmd) with custom argument with asp.net -


i have small asp.net web-form application.i trying run cmd.exe given command.i publishing project server cannot debug on server.

first , tried dir command working should be

       system.diagnostics.process si = new system.diagnostics.process();         si.startinfo.workingdirectory = "c:\\";         si.startinfo.useshellexecute = false;         si.startinfo.filename = "cmd.exe";         si.startinfo.username = "administrator";         si.startinfo.password = new securestring();         si.startinfo.arguments = @"/c dir";         si.startinfo.createnowindow = true;         si.startinfo.redirectstandardinput = true;         si.startinfo.redirectstandardoutput = true;         si.startinfo.redirectstandarderror = true;          foreach (char c in "pass*")             si.startinfo.password.appendchar(c);          si.start();         string error = si.standarderror.readtoend();         string output = si.standardoutput.readtoend();         si.waitforexit();         si.close();        if (!string.isnullorempty(error.trim()))         {             throw new exception("command cannot executed");         }          //pre-created .bat file         if (file.exists(@"c:\test\s.bat"))         {             using (streamwriter sw = file.appendtext(@"c:\test\s.bat"))             {                 sw.writeline(output);             }         } 

**when check .bat file.it written directories under c:/ , working

second , tried send custom command execute cmd.exe

the command(argument) passed :

c:\dev6i\bin\rwrun60.exe userid=user/pass report="h:\avicenna\uyg6i\mikr2392" background="no" batch="yes" desformat="pdf" desname="c:\test\reports\report_l_23123_121213.pdf" destype="file"  paramform="no" patid="131233" prono="6472886" groub="3" 

it executing report program(rwrun60.exe) parameters , program trigger another(which on h:/ network folder) create report pdf on local machine's "c:\test\reports\" folder. when copied , paste text command line(cmd.exe) working without problem , pdf created.

here code this:

       system.diagnostics.process si = new system.diagnostics.process();         si.startinfo.workingdirectory = @"c:\test\";         si.startinfo.useshellexecute = false;         si.startinfo.filename = "cmd.exe";         si.startinfo.username = "administrator";         si.startinfo.password = new securestring();         si.startinfo.arguments = result.command; //result.command argument text above        // si.startinfo.arguments = @"/c "+result.command; //also tried , unsure /c necessary         si.startinfo.createnowindow = true;         si.startinfo.redirectstandardinput = true;         si.startinfo.redirectstandardoutput = true;         si.startinfo.redirectstandarderror = true;          foreach (char c in "pass*")             si.startinfo.password.appendchar(c);          si.start();         string error = si.standarderror.readtoend();         string output = si.standardoutput.readtoend();         si.waitforexit();         si.close();          if (!string.isnullorempty(error.trim()))         {             throw new exception("error occured");         }          if (file.exists(@"c:\test\s.bat"))         {             using (streamwriter sw = file.appendtext(@"c:\test\s.bat"))             {                 sw.writeline(output);             }          } 

** these codes , run error.but command not working reason pdf isn't created. test folder has iis_usr privileges full control.i sure argument dont know do. should check?


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -