通过VBExcel自动化Putty

时间:2017-07-10 12:08:30

标签: excel vba

我想通过Excel VBA自动执行以下过程: 1.打开Putty特定路径 2.使用凭据登录 3.导航到服务器中的路径。 (cd / folder1 / folder2) 我可以做1& 2.由于我是VBA的新手,我不知道如何获得第三名。

1 个答案:

答案 0 :(得分:0)

Public Sub Test()
  Dim PuttyPID as Long, username as String, password as String
  username= " xxxxxx": Password= "123456"
  P1 = "C:\Program Files (x86)\PuTTy\putty.exe - ssh" & username & _
    "@xx.yyy.zzz.aaa - pw" & Password
  PuttyPID = Shell(P1, 1)

  '''''''''''''''''''''''''''''''''''''''''''
  Application.Wait Now + TimeSerial(0, 0, 20) ' <-- give it time to get server prompt
  AppActivate PuttyPID ' <-- activate it again to make sure
  SendKeys "cd /folder1/folder2" & vbCr ' <-- vbCR to simulate CR key
End Sub