0

Below is the Current Script I have for my current little project.

<job>
    <script language="VBScript">
    Option Explicit
    On Error Resume Next
    Dim WshShell
    set WshShell=CreateObject("WScript.Shell")
    WshShell.run "cmd.exe", 2
    WScript.Sleep 50
    'Send commands to the window as needed - IP and commands need to be customized
    'Step 1 - Telnet to remote IP'
    WshShell.SendKeys "telnet 192.168.0.1 23"
    WshShell.SendKeys ("{Enter}")
    WScript.Sleep 50
    WshShell.SendKeys ("root{Enter}")
    WScript.Sleep 50
    WshShell.SendKeys ("foo{Enter}")
    WScript.Sleep 50
    WshShell.SendKeys ("cd /work/Tools{Enter}")
    WScript.Sleep 50
    WshShell.SendKeys ("control_videosignal.sh -fbas 1{Enter}")
    WScript.Sleep 50 
    WshShell.SendKeys "exit{ENTER}" 'close telnet session' 
    WshShell.SendKeys "{ENTER}" 'get command prompt back 
    WScript.Sleep 50 
    WshShell.SendKeys "exit{ENTER}" 'close cmd.exe
    WshShell.SendKeys "{ENTER}" 'get command prompt back 
    WScript.Sleep 1000
    WshShell.SendKeys "{ENTER}" 'get command prompt back 
    WScript.Sleep 200 
    WshShell.SendKeys "exit{ENTER}" 'close cmd.exe
    </script>
    </job

The result is it stops at this point.

Stops here

I just want the current cmd.exe window to close when the script exits.

Any help is appreciated.

WshShell.SendKeys ("control_videosignal.sh -fbas 1{Enter}")
WScript.Sleep 50
WshShell.SendKeys ("{Enter}")
WScript.Sleep 200
WshShell.SendKeys "^{C}"
WScript.Sleep 200
WshShell.SendKeys ("exit{Enter}")
WScript.Sleep 3000
WScript.Quit
</script>
</job>

Connection Just closes without Executing.

1 Answer 1

1

It looks like you're stuck in Telnet, which uses the command quit rather than exit I believe.

Try using:

WshShell.SendKeys "quit{ENTER}"

or

WshShell.SendKeys "^{C}"

To make sure you've properly quit Telnet, before issuing exit to cmd.

8
  • I will try these in a few. Feb 17, 2016 at 10:05
  • Tried using Quit was not Recognized. Im using Telnet through CMD. as for the other the script crashes. Any other idea or maybe my Script is interfering with something? Feb 17, 2016 at 10:36
  • No, it is not executing and just closing the window. I will add how I have it placed one second. Feb 17, 2016 at 10:39
  • Alright its up. Let me know what you think. Feb 17, 2016 at 10:44
  • And yes the .sh file is hosted on the Device im Connecting to its a work project. Feb 17, 2016 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.