You must Sign In to post a response.
  • Category: ASP.NET

    How to run Command Prompt commands from VB.NET?

    I have an application which build in never learn VB.I have worked on I run it's setup and execute it,I able to see command prompt.But when I using this application for scheduling task/creating task and scheduling, unable to see command prompt.

    I am using following code that create process.

    Dim Cw As New ProcessStartInfo(name, name & " " & name)
    Cw.WindowStyle = ProcessWindowStyle.Maximized
    Is there is any other way to do this?Without making a process can I execute shell program?I am working on windows8 opeating system
  • #763398
    Hello Pinky,

    You can do by using executing process :

    System.Diagnostics.Process.Start("cmd", "/c cls") // cls is the command to clear the screen. Instead of cls you can execute your commands.

    Hope this will help you.

    If you still facing the problem let me know.

    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #763402

  • #763426
    Check this out

    System.Diagnostics.Process() objProcess = new System.Diagnostics.Process(); // Create the process object
    objProcess.StartInfo.FileName = "c:\\Anil\\testAnil; //batch File Name
    objProcess.StartInfo.Arguments = "c:\\Anil\\testAnil" + strXmlFileName; // passing the paramter file name
    objProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
    //Wait until the process passes back an exit code
    //Free resources associated with this process
    catch (Exception ex)
    MessageBox.Show("Could not start process " + FileNameNew, "Error");

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #763528
    Process class with parameters will always good call to run commands from .net
    see below snippet
    Shared Sub RunCommandCom(command as String, arguments as String, permanent as Boolean)
    Dim p as Process = new Process()
    Dim pi as ProcessStartInfo = new ProcessStartInfo()
    pi.Arguments = " " + if(permanent = true, "/K" , "/C") + " " + command + " " + arguments
    pi.FileName = "cmd.exe"
    p.StartInfo = pi
    End Sub

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • Sign In to post your comments