run VBScript on multiple IPs -


i have vbs file connects telnet old hardware. want run vbs on multiple ips.

what should change in telnet script in order select ips txt file , run script on each ip?

something ping example below without output file.

telnet vbs file:

option explicit dim oshell set oshell = wscript.createobject("wscript.shell") oshell.run "telnet" wscript.sleep 4000 oshell.sendkeys "open 192.168.194.82~" wscript.sleep 4000 oshell.sendkeys "admin~" wscript.sleep 4000 oshell.sendkeys "this password~" wscript.sleep 4000 oshell.sendkeys "system~" wscript.sleep 4000 oshell.sendkeys "restart~" oshell.sendkeys "yes~" wscript.quit 

ping example:

dim strinputpath, stroutputpath, strstatus dim objfso, objtextin, objtextout  strinputpath = "c:\ip-list.txt" '- location of input stroutputpath = "c:\ip-list-output.csv" '- location of output  set objfso = createobject("scripting.filesystemobject") set objtextin = objfso.opentextfile(strinputpath, 1) set objtextout = objfso.createtextfile(stroutputpath) objtextout.writeline("computer,status")  until objtextin.atendofstream = true     strcomputer = objtextin.readline     if fpingtest(strcomputer)          strstatus = "up"     else          strstatus = "down"     end if     objtextout.writeline(strcomputer & "," & strstatus) loop  function fpingtest(strcomputer)     dim objshell, objping     dim strpingout, flag     set objshell = createobject("wscript.shell")     set objping = objshell.exec("ping " & strcomputer)     strpingout = objping.stdout.readall     if instr(lcase(strpingout), "reply")         flag = true     else         flag = false     end if     fpingtest = flag  end function 


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -