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 vb.net.I never learn VB.I have worked on C#.net.when 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
    Process.Start(Cw)
    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.

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

  • #763402
    http://www.dotnetutorial.com/display-code.aspx?id=5
    Regards,
    Programmer

    http://www.dotnetutorial.com/interview-questions.aspx?catid=1

  • #763426
    Check this out



    try
    {
    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;
    objProcess.Start();
    //Wait until the process passes back an exit code
    objProcess.WaitForExit();
    //Free resources associated with this process
    objProcess.Close();
    }
    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
    p.Start()
    End Sub

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


Sign In to post your comments