Board index » Visual Studio » IPCONFIG /ALL Script... something missing
|
MickDoherty
|
IPCONFIG /ALL Script... something missing
Visual Studio352
All- I am trying to write up a small VBScript that will run the ipconfig /all command on a list of servers in a text file and output the results to another text file. I've run into one issue. When I run the script, instead of writing all of the ipconfig /all results to the output file, it writes the results of the first server only (and it repeats that for however many servers I have in the input file). Here is what I have now: Const ForAppending = 2 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile _ ("c:\results.txt", ForAppending, True) Const INPUT_FILE_NAME = "C:\servers.txt" Const FOR_READING = 1 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(INPUT_FILE_NAME,FOR_READING) strComputers = objFile.ReadAll objFile.Close arrComputers = Split(strComputers, vbCrLf) For Each strComputer In arrComputers Set objShell = CreateObject("WScript.Shell") Set objScriptExec = objShell.Exec("ipconfig /all") strIpConfig = objScriptExec.StdOut.ReadAll For Each ?????????????????????? objTextFile.WriteLine(strIpConfig) Next Next objTextFile.Close ------------ The line containing "For Each ??????????????????????" is the line where I know I'm missing the For Each.. but I can't seem to get it right. Any ideas? Thanks. - |
