Open Command Prompt Command

SOLVED Discussion in 'Web Design & Coding' started by Comptech, Dec 11, 2011.

  1. Comptech

    Comptech ICT Technican

    Joined:
    Dec 11, 2011
    Messages:
    16
    Likes Received:
    14
    Location:
    UK
    Here is how to open command prompt and keep window open with information already displayed

    Dim Command As String
    Command = "ipconfig /all"
    Shell("cmd /k" & Command, 1, True)

    pleace this in a click event

    Kind Regards

    Bradley
     
    Comptech, Dec 11, 2011
    #1
    Zeus likes this.
    1. Advertisements

  2. Comptech

    AceInfinity Somewhere...

    Joined:
    Aug 13, 2012
    Messages:
    7
    Likes Received:
    0
    Location:
    Canada
    Shell isn't advised in my opinion. You can use the System.IO Process class to do the same thing.

    Code:
    Public Sub MainMethod(cmdName As String)
    	Dim Proc As New Process
    	Dim ProcInfo As New ProcessStartInfo
    	With ProcInfo
    		.FileName = "cmd.exe"
    		.Arguments = String.Format("/k {0}", cmdName)
    		.UseShellExecute = False
    		.Verb = "runas"
    		.WindowStyle = ProcessWindowStyle.Normal
    	End With
    
    	Proc.StartInfo = ProcInfo
    	Proc.Start()
    End Sub
     
    AceInfinity, Aug 13, 2012
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.