How to make a CMD application in vb 2008!
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
6 posts
Page 1 of 1
What we gonna need?
Button1 = btnSend
Textbox1 = txtCommand
Textbox2 = txtResults
Basicly there is not much to explain in this code, but basicly it just recieves and sends codes as if it were command prompt, why would you need this? well if CMD is delete and everthing else is disabled, such as internet explorer and other stuff(i am referring to a virus) you can call a command such as calling a system restore so it will undo changes, like downloading the virus, or you can CALL IN A AIRSTRIKE and bomb the virus, not really. But this is cool and usefull!
:mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen:
Button1 = btnSend
Textbox1 = txtCommand
Textbox2 = txtResults
Basicly there is not much to explain in this code, but basicly it just recieves and sends codes as if it were command prompt, why would you need this? well if CMD is delete and everthing else is disabled, such as internet explorer and other stuff(i am referring to a virus) you can call a command such as calling a system restore so it will undo changes, like downloading the virus, or you can CALL IN A AIRSTRIKE and bomb the virus, not really. But this is cool and usefull!
:mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen:
Code: Select all
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents btnSend As System.Windows.Forms.Button
Friend WithEvents txtCommand As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents txtResults As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
Me.btnSend = New System.Windows.Forms.Button
Me.txtResults = New System.Windows.Forms.TextBox
Me.txtCommand = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'btnSend
'
Me.btnSend.Location = New System.Drawing.Point(11, 8)
Me.btnSend.Name = "btnSend"
Me.btnSend.Size = New System.Drawing.Size(96, 23)
Me.btnSend.TabIndex = 0
Me.btnSend.Text = "Send Command"
'
'txtResults
'
Me.txtResults.BackColor = System.Drawing.Color.Black
Me.txtResults.ForeColor = System.Drawing.Color.Lime
Me.txtResults.Location = New System.Drawing.Point(8, 40)
Me.txtResults.Multiline = True
Me.txtResults.Name = "txtResults"
Me.txtResults.ReadOnly = True
Me.txtResults.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.txtResults.Size = New System.Drawing.Size(496, 249)
Me.txtResults.TabIndex = 1
'
'txtCommand
'
Me.txtCommand.Location = New System.Drawing.Point(240, 8)
Me.txtCommand.Name = "txtCommand"
Me.txtCommand.Size = New System.Drawing.Size(100, 20)
Me.txtCommand.TabIndex = 2
Me.txtCommand.Text = "dir"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(120, 8)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(112, 23)
Me.Label1.TabIndex = 3
Me.Label1.Text = "Command To Send:"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(512, 296)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.txtCommand)
Me.Controls.Add(Me.txtResults)
Me.Controls.Add(Me.btnSend)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "CMD Total Comand v1.2"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim CMDThread As New Threading.Thread(AddressOf CMDAutomate)
CMDThread.Start()
End Sub
Private Sub CMDAutomate()
Dim myprocess As New Process
Dim StartInfo As New System.Diagnostics.ProcessStartInfo
StartInfo.FileName = "cmd" 'starts cmd window
StartInfo.RedirectStandardInput = True
StartInfo.RedirectStandardOutput = True
StartInfo.UseShellExecute = False 'required to redirect
myprocess.StartInfo = StartInfo
myprocess.Start()
Dim SR As System.IO.StreamReader = myprocess.StandardOutput
Dim SW As System.IO.StreamWriter = myprocess.StandardInput
SW.WriteLine(txtCommand.Text) 'the command you wish to run.....
SW.WriteLine("exit") 'exits command prompt window
txtResults.Text = SR.ReadToEnd
SW.Close()
SR.Close()
End Sub
------------------------------------------------------------------------------
Proprogrammer, not just a Programmer.
Proprogrammer, not just a Programmer.
Visual Studio comes with built in support for console applications.
Code: Select all
While True
Console.WriteLine("Command?")
Dim input As String = Console.ReadLine()
If input = Nothing Then
Return
End If
Try
Shell(input)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End While
Thanks dude i didnt know that!


------------------------------------------------------------------------------
Proprogrammer, not just a Programmer.
Proprogrammer, not just a Programmer.
Thanks mandai, I've sent you a PM. Have you seen it yet?
well i thnk Proprogrammer just cracked a program
6 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023