.net - Issue with running a bat file programatically from a com interop dll on classic asp -
.net - Issue with running a bat file programatically from a com interop dll on classic asp -
i facing predicament running bat file using system.diagnostics.process object. have code running bat file in class library compiled dll. made dll com interoperable registering using compile time. signed using strong key, exported type library , set dll gac using regasm , gacutil commands. created object of specific class in dll has method bat file execution using server.createobject method in vbscript. called method bat execution. method gets invoked alright cmd prompt not popping nor bat file beingness executed. checked see if problem interop dll dll worked fine vb6 code. can help me issue? not sure if permission issue on iis server. or cmd executions not possible via vbscript on asp dlls?
thanks, geo.
apparently may need run cmd , inject input it:
// total file path string strfilepath = "c:\\temp\\test.bat"; // create processinfo object system.diagnostics.processstartinfo psi = new system.diagnostics.processstartinfo("cmd.exe"); psi.useshellexecute = false; psi.redirectstandardoutput = true; psi.redirectstandardinput = true; psi.redirectstandarderror = true; psi.workingdirectory = "c:\\temp\\"; // start process system.diagnostics.process proc = system.diagnostics.process.start(psi); // open batch file reading system.io.streamreader strm = system.io.file.opentext(strfilepath); // attach output reading system.io.streamreader sout = proc.standardoutput; // attach in writing system.io.streamwriter sin = proc.standardinput; // write each line of batch file standard input while(strm.peek() != -1) { sin.writeline(strm.readline()); } strm.close(); // exit cmd.exe string stechofmt = "# {0} run successfully. exiting"; sin.writeline(string.format(stechofmt, strfilepath)); sin.writeline("exit"); // close process proc.close(); // read sout string. string results = sout.readtoend().trim(); // close io streams; sin.close(); sout.close(); http://codebetter.com/brendantompkins/2004/05/13/run-a-bat-file-from-asp-net/
.net com interop asp-classic cmd
Comments
Post a Comment