CMD prompt

I'm tring to open the command prompt from within my application it does seem to work with the code i used:

 

Dim obj as new cmd

cmd = "c:\WINDOWS\_default.bat"

 

or even this

me.show("c:\WINDOWS\_default.bat")

or show("autoexec.bat")

 

can someone help me please...



Answer this question

CMD prompt

  • cnathan

    Protected Sub CreateProcess(byval filespec as string)

    Dim startinfo As New System.Diagnostics.ProcessStartInfo

    Dim Proc As New System.Diagnostics.Process

    startinfo.FileName = "c:\windows\system32\cmd.exe"

    startinfo.UseShellExecute = True

    startinfo.Arguments = filespec

    Proc.StartInfo = startinfo

    Try

    Proc.Start()

    Catch e As Exception

    MsgBox("You have requested to run file:" & vbCrLf & vbCrLf & packet.sFileSpec & vbCrLf & _

    vbCrLf & "However that file is not in that directory. You may either delete this button" & vbCrLf & _

    "or replace the effected file.", MsgBoxStyle.Critical, e.Message)

    End Try

    End Sub



  • Sairam_1974

    Thank you for the response on my problem. I'm sorry but i either don't understand or can't get it to work.

    here is the script i'm working with. I want the CommandPromptToolStrip to open the cmd.exe

    Do you have any ideas on how to impliment that.

    Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub ShowMyInboxToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowMyInboxToolStripMenuItem.Click

    Dim inbox As New Messenger

    inbox.Show()

    End Sub

    Private Sub CommandPromptToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CommandPromptToolStripMenuItem.Click

    End Sub

    Protected Sub CreateProcess(ByVal filespec As String)

    Dim startinfo As New System.Diagnostics.ProcessStartInfo

    Dim Proc As New System.Diagnostics.Process

    startinfo.FileName = "c:\windows\system32\cmd.exe"

    startinfo.UseShellExecute = True

    startinfo.Arguments = filespec

    Proc.StartInfo = startinfo

    Try

    Proc.Start()

    Catch e As Exception

    ' MsgBox("You have requested to run file:" & vbCrLf & vbCrLf & packet.sFileSpec & vbCrLf & vbCrLf & "However that file is not in that directory. You may either delete this button" & vbCrLf & "or replace the effected file.", MsgBoxStyle.Critical, e.Message)

    End Try

    End Sub

    End Class


  • CMD prompt