ASP.NET - How to Execute .cmd file in - Asked By Nagaraju on 05-Sep-11 01:25 AM

Hi ,
  I have a .cmd file. in that file i am running a Java class. I trying to run this .cmd from my .net application Using System.Diagnostics.ProcessStartInfo class but i am getting an Exception 'NO CLASS DEFINITION FOUND'. Can anyone help me?????

Thank You,
Cos mos replied to Nagaraju on 05-Sep-11 02:06 AM

ProcessStartInfo psi = new ProcessStartInfo("[CMD FileName]");

Process p = new Process();

p.StartInfo = psi;


Please refer the below link for more information
Reena Jain replied to Nagaraju on 05-Sep-11 02:13 AM

try this and let me know

  1. <%
  2. Dim info As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo("C:\\Program Files\\Web Content Extractor\\WCExtractor.exe", """C:\\Documents and Settings\\hama\\Desktop\\Teachnetworkscrapjobs\\Scrapfiles\\abc-teachers.wcepr"" -dr -rt -s -ddr -qe -ex")
  3. Dim p = System.Diagnostics.Process.Start(info)
  4. p.Start()
  5. %>
Hope this will help you
Anoop S replied to Nagaraju on 05-Sep-11 02:58 AM

1. Create a scheduled task which simply executes a batch file, say c:\mybatch.bat. You can disable this scheduled task because you don't really want it to run on a schedule, but rather when you tell it to.

2. Create a new file which contains the path and filename of the batch file you really want to execute, and save this new file as c:\mybatch.bat (such that when the scheduled task is run, it will execute this new batch file).

3. In your web app code, create a new process which will simply run the schedule task, as follows: myprocess.StartInfo = new ProcessStartInfo("cmd.exe", "schtasks /run /TN \"task-name\"");