I am trying to remotely flushdns multiple servers remotely and output the results to a textfile. After running my script, my textfile is empty.
Script:
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set wshShell = WScript.CreateObject("WSCript.shell")
Set textFile = fso.OpenTextFile("C:\Scripts\servers.txt", ForReading)
Set logFile = fso.CreateTextFile("C:\Scripts\logsssss.txt")
Do Until textFile.AtEndOfStream
hostName = textFile.Readline
Do
wshShell.run("cmd /c psexec \\" & hostName &" -u IDEALCORP\acorrera -s ipconfig /flushdns >> & hostName,TRUE")
Loop Until True
Loop
Any ideas why my output is blank? What needs to be changed/modified in my script?
Quotes are not in their place and it is better to include window style in Run method
NO : wshShell.run "cmd /c psexec \\" & hostName &" -u IDEALCORP\acorrera -s ipconfig /flushdns >> & hostName,TRUE"
YES : wshShell.run "cmd /c psexec \\" & hostName &" -u IDEALCORP\acorrera -s ipconfig /flushdns >> " & hostName,0,TRUE