0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

teratermマクロをExcelVBAで作成する

Last updated at Posted at 2023-01-10

次のようにExcelで作成する

A1にNoを持ってきてください

image.png


Sub teraterm()

start_count = 2

Max = Cells(1, 1).End(xlDown).Row

For i = 2 To Max


'B列 6行目からスタート
  UserName = Cells(i, 2).Value
  Password = Cells(i, 3).Value
  hostname = Cells(i, 4).Value
  IPADDR = Cells(i, 5).Value
  INIFILE = Cells(i, 6).Value
 
'マクロ作成

    Dim ttlPATH As String
    Dim FN As Integer

    ttlPATH = "C:\work\" + hostname + ".ttl"
    INIFILE = "C:\work\TERATERM.INI"
    FN = FreeFile

    Open ttlPATH For Output As #FN
    Print #FN, "COMMAND = '" + IPADDR + "'"
    Print #FN, "strconcat COMMAND ':22 /ssh /2 /auth=password /user='"
    Print #FN, "strconcat COMMAND '" + UserName + "'"
    Print #FN, "strconcat COMMAND ' /passwd='"
    Print #FN, "strconcat COMMAND '" + Password + "'"
    Print #FN, "strconcat COMMAND ' /f='"
    Print #FN, "strconcat COMMAND '" + INIFILE + "'"
    Print #FN, "connect COMMAND"
    Print #FN, "end"
    
    Close #FN
 Next
 End Sub




参考URL
https://qiita.com/Diavolo/items/30a12f8e533f0bf806b6

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?