Reputation: 21
I created a hyperlink in a pdf, this hyperlink is tied to vbs script, until this step all ok. When I run the script manually (double click), the script does that I want (open telnet connection). The problem is when I run the script through the hyperlink, CMD show the message " "telnet" is not recognized as an internal or external command". Please, Can anyone tell me why occurs that??
This is the script:
Dim WshShell, regexp
set regular = New RegExp
direccion = inputbox("Ingresa ip del equipo:")
' Set pattern.
regular.Pattern = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
' Set case insensitivity.
regular.IgnoreCase = True
' Set global applicability.
regular.Global = True
if regular.test(direccion) = TRUE then
set WshShell=CreateObject("WScript.Shell")
WshShell.run "cmd.exe"
WScript.Sleep 1000
'Send commands to the window as needed - IP and commands need to be customized
'Step 1 - Telnet to remote IP'
WshShell.SendKeys "telnet " & direccion
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
else
msgbox "Ingresa una ip válida"
end if
Upvotes: 0
Views: 709
Reputation: 703
Telnet isn't in my Windows 10 and 8. But anyway if you have "telnet" command couldn't you do:
WshShell.run "cmd.exe /k telnet"
That should work and saves space.
Upvotes: 0
Reputation: 8121
probably working directory not set correctly.
try
WshShell.SendKeys "c:\windows\system32\telnet.exe " & direccion
p.s: you're doing it wrong. "sendkeys" is somehow understandable when telnet terminal is already running, but there is no reason to be manually sending keys to the standard command prompt.
Upvotes: 1