Skip to content
ELECTRONICS ENGINEERINGelectronics-engineering.com
DOS

How to Run Commands Remotely Directly from the Windows CMD

PuTTY is an excellent tool for connecting remotely, but you also need plink to run remote commands directly from the cmd command line. Using PuTTY from the command line…

https://www.electronics-engineering.com/en/how-to-run-commands-remotely-directly-from-the-windows-cmd/

Was this page useful? Rate it:
average 4.0 from 1 rating

PuTTY is an excellent tool for connecting remotely, but you also need plink to run remote commands directly from the cmd command line

Using PuTTY from the command line will create an interactive SSH session. This may not be what we want if, for example, we need to stay at the Windows command line or we want to issue an SSH command inside a script. To meet this kind of need, PuTTY provides a tool called Plink

Plink is a command-line tool that will let you log in to a remote computer using SSH and create an SSH session or run a command, all from the command line and without opening another window. Plink comes with many command-line options that can be read with the -h option…

This article describes in detail a method, via VBS and DOS, for sending remote commands over telnet

@ECHO OFF
  :: :::::::::::::::::::::::::::::::::::::::::::::
  :: temp_SendKeys.VBS will contain the "commands"
  ECHO.set handler=WScript.CreateObject("WScript.Shell")>temp_SendKeys.VBS
  ECHO.WScript.sleep 500 >>temp_SendKeys.VBS


  :: :::::::::::::::::::::::::::::::::::::::::::::
  :: Open Connection To Telnet Host
  ECHO.handler.SendKeys "open telnet.com~" >>temp_SendKeys.VBS
  ECHO.WScript.sleep 500 >>temp_SendKeys.VBS


  :: :::::::::::::::::::::::::::::::::::::::::::::
  :: Send Login Name
  ECHO.handler.SendKeys "mylogin~" >>temp_SendKeys.VBS
  ECHO.WScript.sleep 500 >>temp_SendKeys.VBS
  :: Send Password
  ECHO.handler.SendKeys "mypassword~" >>temp_SendKeys.VBS
  ECHO.WScript.sleep 500 >>temp_SendKeys.VBS
  

  :: :::::::::::::::::::::::::::::::::::::::::::::
  :: Send Stuff to be done
  ECHO.handler.SendKeys "dir~" >>temp_SendKeys.VBS
  ECHO.WScript.sleep 1500 >>temp_SendKeys.VBS


  :: :::::::::::::::::::::::::::::::::::::::::::::
  :: Logout
  ECHO.handler.SendKeys "exit~" >>temp_SendKeys.VBS
  ECHO.WScript.sleep 250 >>temp_SendKeys.VBS
  ECHO.handler.SendKeys " " >>temp_SendKeys.VBS
  ECHO.WScript.sleep 250 >>temp_SendKeys.VBS
  ECHO.handler.SendKeys "quit~" >>temp_SendKeys.VBS
  ECHO.WScript.sleep 250 >>temp_SendKeys.VBS


  :: Open a Telnet Windows
  start telnet.EXE


  :: Run the script
  cscript//nologo temp_SendKeys.VBS


  :: Delete the temporary file 
  DEL temp_SendKeys.VBS
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
1
0
Would love your thoughts, please comment.x
()
x