I'm trying to automate a telnet script into a button on an excel spreadsheet.
The user puts info into two cells, and the script uses those values in the script.
The problem I'm finding is that this is only working some of the time - more often than not,
the enter key will be pressed despite using the same sendkeys directly above it --
this is causing whole lines and in some cases partial lines (
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub PerformSendKey(ByVal line As String)
SendKeys String:=line, wait:=True
SendKeys String:="{enter}", wait:=True
Sleep 1500
End Sub
Private Sub CommandButton1_Click()
Application.EnableCancelKey = xlErrorHandler
On Error GoTo ErrHandler
i = Shell("C:\Windows\System32\cmd.exe", vbNormalFocus)
Sleep 2000
PerformSendKey ("telnet")
PerformSendKey ("open " + MachineID)
PerformSendKey ("user")
PerformSendKey ("password")
PerformSendKey ("db2cmd -i -w")
PerformSendKey ("db2 connect to host")
ErrHandler:
Exit Sub
End Sub
One thing always works though -- the password, when the script glitches out it misses the top couple of lines and presents the password in plain text, when the script doesn't glitch out, the password also always works.
I can't figure out why only the password line is reliable.
How can I make sure, that every time the button is pressed -- it always works?
Thanks
This post has been edited by Saldash: 10 March 2012 - 12:17 PM

New Topic/Question
Reply




MultiQuote







|