VBS script to search .csv file for specific text and add user inputed data into specific columns
<p>I have a hardware inventory audit script that creates a .csv file ( see audit_results ). This results file can contain the audit from 30 or more computers on the local network. I run this script from the login.bat on the server. </p>

<p>I now want to run a script / batch file locally on each pc that will </p>

<ol>
<li>Search the csv results for the current computername.</li>
<li>If comptuer name isn't found then rerun audit ( a separate vbs script )</li>
<li>If computer name found </li>
<li>Ask to input the following Monitor, Attached Devices and New bios version.</li>
<li>This data is then placed into the csv file in columns 5,6 and 17 within the same line containing the pc name. </li>
</ol>

<p>Any help suggestions much appreciated.</p>

<p>So far I have the following vbs script....</p>

<pre><code>`On Error Resume Next

Const HKEY_LOCAL_MACHINE = &amp;H80000002
Const HKEY_CURRENT_USER = &amp;H80000001

strIPvalue = "."

CALL GenerateReport(strIPvalue)


'=================================================================================
SUB GenerateReport(strIPvalue)
'Get logon server name from environment variable

Set oShell = CreateObject("Wscript.Shell")
Set WshSysEnv = oShell.Environment("PROCESS")
sLogonServer = WshSysEnv("LOGONSERVER")

strPath = sLogonServer &amp; "\data\Audit\" 

'=================================================================================

'Variable Declarations
Const ForReading = 1, ForWriting = 2, ForAppending = 8

'===============================================================================
'Main Body
On Error Resume Next


'Search csv for current pc name and if not found rerun auditscript

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strPath &amp; "Audit_Results.csv", ForReading)

Set wshshell = CreateObject("WScript.Shell")
Set ObjEnv = WshShell.Environment("Process")
COMPNAME = ObjEnv("COMPUTERNAME")

Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
If InStr(strLine,COMPNAME) = ObjEnv("COMPUTERNAME") then 


'rerun audit script if computername not found
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.Run wscript strPath &amp; "Run_Audit.vbs"  

End If
Loop

objFile.Close


end sub
</code></pre>

<p>Audit_Results.csv
Date;Computer Naam;Manufacturer;Model;Monitor;Attached Devices;Printers;IE version;Processor;Domain Naam;Workgroup;Installed O/S;OS Version;Service Pack;Serial Nummer;Bios;Bios Nieuw;Total Memory (GB);Network Adapters;Applications
monday 23 juli 2012;MYLAPTOP;Dell Inc.;Latitude E5520;;;USB001 - Samsung 5275CX;8.0.7601.17514;Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz;;WORKGROUP;Microsoft Windows 7 Professional |C:\Windows|\Device\Harddisk0\Partition3;6.1.7601;1.0;XYZXYZ;A05;;4;Broadcom NetXtreme 57xx Gigabit Controller /DW1501 draadloze N WLAN Half Mini-kaart /; </p>
