Once this part is resolved I will add the rest of the code which sends
additional commands, which is not a problem.
_____________________________
'Get Username and Password
user = inputbox("Please Enter Username")
pass = inputbox("Please Enter Password")
'Create the shell object
Set oShell = CreateObject("WScript.Shell")
'Start up command prompt
oShell.run"cmd.exe"
WScript.Sleep 500
'Send keys to active window
oShell.SendKeys"telnet xxx.xxx.xxx.xxx"
'Emulate the enter key
oShell.SendKeys("{Enter}")
WScript.Sleep 1000
'write the username to the cmd window
oShell.SendKeys("[%user%]")
oShell.SendKeys("{Enter}")
WScript.Sleep 500
'write the password to the cmd window
oShell.SendKeys("[%pass%]")
oShell.SendKeys("{Enter}")
WScript.Sleep 500
oShell.SendKeys"ls"
oShell.SendKeys("{Enter}")
WScript.Sleep 500
'Exit the program
oShell.SendKeys"% "
_________________________
> oShell.SendKeys("[%user%]")
> oShell.SendKeys("[%pass%]")
Not sure if calling a variable in using the SendKeys shell command is
possible. If so, not sure of context. Tried several combinations, but no
luck. Thanks for anyone's input.
Your script is completely dependent on macros. Unfortunately macro programs
are notorious for failing for all sorts of reasons. If you want something
robust and stable then you must avoid them. Have a look at this thread about
a method that avoids macros. Post again if you need more help with
implementing your particular project.
http://groups.google.com/group/microsoft.public.scripting.vbscript/browse_thread/thread/529c7776bdb5bb24
That said, it looks like he is assuming that environment variables and
vbscript variables are one and the same. I agree that sendkeys is a method
of last resort, but he could try changing, for example:
>> oShell.SendKeys("[%user%]")
to:
>> oShell.SendKeys(user)
/Al
Yes, AutoIt is far more reliable in sending keys to a window than sendkeys.
With Autoit you can wait until a certain window comes up and do not risk to send
keystrokes to something else if the user switches to another window.
I tried a small program called NetCat which allows to open a connection and send data from
a text file.
wshShell.run "%comspec% /C nc.exe " & server & " 110 <command.txt >output.txt",7,true
--
Giovanni Cenati (Bergamo, Italy)
Write to "Reventlov" at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--