Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get VBS to read from text file?
    primarykey
    data
    text
    <p>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.</p> <pre><code>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:" &amp; "{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\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 = " &amp; Chr(34) &amp; arrSoftwareList(0) &amp; Chr(34) ) For Each objSoftware in colSoftware objSoftware.Uninstall() strOutput = stroutput &amp; vbCrLf &amp; objsoftware.Name Next Loop WScript.Echo strOutput </code></pre> <p>Content of the Computer_Names.txt file would just be something like this. Each computer on a separate line of text.</p> <pre><code>LAPD2712 LAPD2812 </code></pre> <p>All our computer names are 4 upper-case letters, 4 numbers.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload