title: output net view (batch) into text then perform action against each computer
body: <p>I have been trying to find away to search for the existence of my company's software on PC's by searching hostnames on the network <code>\\computername\c$\Program Files\Foo</code>, and if it finds it, copy over an updated config etc.</p>
  
  <p>I've seen that <code>net view</code> will out put all the PC's on the network, something like this:</p>
  
  <blockquote>
  <pre><code>\\DISKSTATION
  \\JWLAPTOP
  \\TEST
  \\XP
  The command completed successfully.
  </code></pre>
  </blockquote>
  
  <p>I was wondering if there was a way to just get the computer names in a clean list (without "command completed" etc.):</p>
  
  <blockquote>
  <pre><code>\\DISKSTATION
  \\JWLAPTOP
  \\TEST
  \\XP
  </code></pre>
  </blockquote>
  
  <p>Then run some commands against it, for everything in <code>hostnames.txt</code>, if exist:</p>
  
  <blockquote>
  <pre><code>\\JWLAPTOP\c$\Program Files\Foo --&gt; do copy xyz to wherever
  </code></pre>
  </blockquote>
  
  <p>I can take care of the part <code>\c$\Program Files\Foo</code> as a variable to add after the computer names in the text file.</p>
  
  <p>Hope that makes sense, thanks for any tips.
  <em>edit</em></p>
  
  <p>Been re thinking this perhaps there is a more direct way to do this....</p>
  
  <p>I need to see the list of PC's on customers network.....net view is a good way of getting this info so far, but I further need to see which ones are online. Any online, query for folder and update a *.CFG file, any offline, output to text for reference. </p>
  
  <p>So at the minute.... </p>
  
  <pre><code>FOR /F "tokens=1 delims= " %%G IN ('net view ^|findstr /L /B /C:"\\"')
  </code></pre>
  
  <p>this is working great, I then made it output to a text file..</p>
  
  <pre><code>FOR /F "tokens=1 delims= " %%G IN ('net view ^|findstr /L /B /C:"\\"') DO (echo %%G&gt;&gt;%~dp0netview.txt) 
  </code></pre>
  
  <p>However, the %%G echo's back \somecomputer which means I am struggling to get a new line..</p>
  
  <p><code>for /f %%G in (%~dp0netview.txt) DO</code> (ping etc......</p>
  
  <p>to ping because of the \ before the computer name. So was wonder if we can make the list 'just" have the PC name without the \ before it.</p>
  
  <p>Also this is the content of the .cfg file I need to edit...</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ClientConfigurationFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;ServerPath&gt;**\\server\shared\data**&lt;/ServerPath&gt;
    &lt;ApplicationMode&gt;Workstation&lt;/ApplicationMode&gt;
    &lt;VRPath /&gt;
    &lt;ServicePollingInterval&gt;0&lt;/ServicePollingInterval&gt;
  &lt;/ClientConfigurationFile&gt;
  </code></pre>
  
  <p>perhaps there is a way of editing a certain section of this directly once its existence is found.  <strong>\server\shared\data</strong>...in bold is what I need to update often when clients have new servers and things and involves having to go round lots of rooms to update manually. This batch could save hours upon hours of unnecessary work.</p>
  
  <p>over writing the existing .cfg file is still a good way of doing it if it's too tricky or not possible directly. </p>
  
  <p>Hope it makes sense, thanks for the replies!!!</p>