Input from a text file



Below, I have posted the part of an inventory script that connects to WMI. Currently I have the script running as a logon GPO. I'd like to change it so I don't have to wait for a user to logon for me to update the inventory. I'd like to be able to connect to each computer remotely. From Microsoft, I got the following that I thought might help. It's not connecting remotely but it's how to read from a text file. Surely, where they say just type the following at the command prompt, they don't mean all the text below. I'm assuming there's been a typo. Can someone help clarify that for me. I'm getting a bit confused with this.

--------------------------------------------------------------------------------
FROM http://www.microsoft.com/technet/scriptcenter/resources/tales/sg1102.mspx#ELDAC
--------------------------------------------------------------------------------
And now here's the script that reads the preceding file. To run this script, you don't need to use any command-line parameters; just type the following at the command prompt and press ENTER:

cscript ListServices.vbs.Const INPUT_FILE_NAME = "C:\Scripts\Computers.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 objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colRunningServices = objWMIService.ExecQuery _
("Select * from Win32_Service")
For Each objService in colRunningServices
Wscript.Echo objService.DisplayName & vbTab & objService.State
Next
Next



--------------------------------------------------------------
PART OF THE INVENTORY CODE
--------------------------------------------------------------
'Change this to the UNC path where inventory files should be created
'Anyone running this script must have read and write access to the
'path.
strInvFilePath = "C:\test\"
'If each user will run this inventory file locally, do not change the value
'of strComputer.
strComputer = "."
'Connect to WMI
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

.



Relevant Pages

  • Re: Input from a text file
    ... So am I right in saying that your core requirement is to collect inventory data about the computer and to have this inventory collection be schedule driven, rather than event driven? ... Currently I have the script running as a logon GPO. ... For Each strComputer In arrComputers ... 'Change this to the UNC path where inventory files should be created ...
    (microsoft.public.scripting.vbscript)
  • Re: Microsoft Software Auditing ?
    ... > wanted to inventory the software installed on the system. ... Overwritten executables will most likely be detected by ... script to do it, as the time invested would not really be worth it. ... but only if you want to detect malicious changes to the system. ...
    (Security-Basics)
  • Re: Inventory script question
    ... I ended up writing a VERY simple script to call the program that writes the inventory to the database. ... If you script the polling into the logon script then you get a whopper of a load every morning when people report for work, which is exactly what you said you wanted to avoid. ...
    (microsoft.public.windows.server.scripting)
  • Re: Inventory script question
    ... I set my script to Sleep for 60 seconds, and the message that popped up was that this version of the Processor did not support UNC pathing. ... I tried to set the DWORD value to 0 this morning, reset the inventory date, and rebooted the machine... ... We've put it into the test group, and applied it as a GPO... ... Alternatively you can use the WriteLine method of the File System Object to write the same information into your log file. ...
    (microsoft.public.windows.server.scripting)
  • Re: Query to test the existence of a folder
    ... wouldn't you have to compile the SMS_def.mof on all clients anyway so really it is a script, ... I'm no SMS admin. ... I disagree, yes I know you don't like me disagreeing with you, but I am disagreeing anyway:-P ... So if you don't mind to inventory all folders on your systems than this shouldn't be that difficult a mofedit. ...
    (microsoft.public.sms.misc)