Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using SendKeys to CMD window
Message
From
08/11/2004 17:29:50
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Using SendKeys to CMD window
Environment versions
Environment:
VB.NET 1.1
OS:
Windows 2000 SP4
Miscellaneous
Thread ID:
00959386
Message ID:
00959386
Views:
54
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
Map
View

Click here to load this message in the networking platform