General information
Title:
Using SendKeys to CMD window
Hi there,
I am trying to automate a script by using sendkeys to a cmd window.
In order to test to see if my text is formatted correctly, I send it first to a textbox.
In the textbox, it looks fine, but when I add the code to send it to a cmd window, the text is partially truncated and/or extra characters are added.
Here is my code:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim strDriveLetter() As String = New String(1) {"y:", "z:"}
Dim strScriptName As String = "drvtst"
Dim strScriptFlags As String = " /f=e /f=l /b=32 /m=640 /i=0 /l=drvtst_cooper_isley_10252004"
Dim strTextSent As String = ""
Dim strLogLetter As String = ""
Dim intCounter = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myProcess As Process = New Process
strLogLetter = strDriveLetter(intCounter)
strLogLetter = strLogLetter.Substring(0, 1)
System.Diagnostics.Process.Start("cmd")
myProcess = System.Diagnostics.Process.GetCurrentProcess()
strTextSent = " " & strScriptName & " " & strDriveLetter(intCounter) & " " & strScriptFlags & strLogLetter & ".log"
TextBox1.Text = strTextSent
System.Windows.Forms.SendKeys.SendWait(strTextSent)
End Sub
End Class
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only