IPTftpHost = "InsertIPHERE" 'This is where the IP is declared.
NameCMDFile = "Runbackup.cmd" 'This is the name of the command file that will be created.
Set fso = CreateObject("Scripting.FileSystemObject") 'Scripting.FileSystemObject declare.
Set f = fso.OpenTextFile(NameCMDFile, 2, True) 'Creating/opening the command file.
Set listFile = fso.OpenTextFile("ListSwitch.txt") 'This is the list of IP addresses of your switches'
Set shell = CreateObject("WScript.Shell") 'WScript shell declare
shell.Run """C:\Program Files (x86)\Tftpd32\tftpd32.exe""", 1, false' We start the TFTP server
Do while not listFile.AtEndOfStream 'This is the start of the loop for the file with the list of switches.
fName = listFile.ReadLine()'Fname is the line read from the file.
Set filetxt = fso.CreateTextFile(fName & ".txt", True)'We create a textfile with the IP of the switch
filetxt.WriteLine("" & _
fName & " 23" & vbCrLf & _'Connection string
"WAIT ""continue"""& vbCrLf & _'Waiting for Continue
"SEND "" \m"""& vbCrLf & _'Sending nothing(Press any key to continue)
"SEND ""copy run tftp "& IPTftpHost & " " & fName & ".cfg"""& vbCrLf & _'This is de important part, this is where you copy RUN over TFTP to your server
"WAIT ""SW"""& vbCrLf & _'Wait for SW(This is for the switch name)
"SEND "" \m"""& vbCrLf & _'Send nothing
"SEND ""logout\m"""& vbCrLf & _'Send the logout command
"WAIT ""log out"""& vbCrLf & _'Wait for log out y/n
"SEND ""y\m"""& vbCrLf & _'Send yes
"SEND ""n\m"""& vbCrLf & _'Send no(this must be done on some switches)
"")'We write the telnet commands to the .txt
filetxt.Close'We close the filestream.
f.WriteLine("tst10 /r:" & fName & ".txt /m")'We write the command to the CMD file.
f.WriteLine("DEL """ & fName & """.txt")'After that we write the delete command to the CMD file.
Loop'End loop
f.WriteLine("taskkill /IM tftpd32.exe") 'We kill the TFTP server
f.WriteLine("MOVE *.cfg %PATH HERE%")'We move all files with .cfg to another location.
f.close'We close the file stream.
shell.Run NameCMDFile, 1, true'We run the CMD file.
fso.deletefile(NameCMDFile)'When it's all done we delete the CMD file.
Now that we have the script, start it and you will see it making back-ups of your RUN configuration.
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (1)
Commented: