I am looking to turn a single computer script into a mass use script. What it does as it stands is allow me to select which parts of Windows Essentials to uninstall by pulling from a text file. However, as it sits, it just prompts for a SINGLE computer name...I want it to pull from a separate text file that I have created Computer_Names.txt, and run the uninstall on all computers in that list. I just can't seem to get it correct.
Const ForReading = 1
strComputer = InputBox("Enter the Computer Name:- ")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("C:\Windows_Live_Components.txt", ForReading)
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
StrOutput = "Uninstalled the following Software:- "
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
arrSoftwareList = Split(strNextLine , ",")
Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product Where Name = " & Chr(34) & arrSoftwareList(0) & Chr(34) )
For Each objSoftware in colSoftware
objSoftware.Uninstall()
strOutput = stroutput & vbCrLf & objsoftware.Name
Next
Loop
WScript.Echo strOutput
Content of the Computer_Names.txt file would just be something like this. Each computer on a separate line of text.
LAPD2712
LAPD2812
All our computer names are 4 upper-case letters, 4 numbers.
You could do something like this:
This loads the data from your text files into arrays then loops on the arrays. I think you previously had an issue with a text stream getting at the
AtTheEndOfStream
and not going back and forth, which would explain why it'd process only the first computer.