[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Bat file to echo list of computers

Posted on 2011-10-24
4
Medium Priority
?
474 Views
Last Modified: 2012-08-13
I am trying to make a bat file that will list all the computers turned on in my building.   They are all part of the same domain.  I can create the list but I am also trying to format the list so that only the computer names show up, one name on each line with no spaces.  I used the command "net view" to list all the computers turned on, on the domain. Then I use the find command to list only the computers I am looking for.  Then I need to remove all the "\\"  and all the white spaces.  Can you help me with this?  Im using windows 7 computers.  
net view > x.txt
find /I "CRL" x.txt > z.txt

Open in new window

0
Comment
Question by:ForLoop5
  • 2
4 Comments
 
LVL 3

Expert Comment

by:telczj9
ID: 37017825
There is a command line utilty called bsed.exe that works very much like sed in unix.  It will allow you to search and replace.

Cheers!
0
 
LVL 59

Accepted Solution

by:
Bill Prew earned 2000 total points
ID: 37017847
Here's a small BAT script that should do the job:

@echo off
setlocal EnableDelayedExpansion
if exist "z.txt" del "z.txt"
for /F "tokens=1" %%A in ('net view ^|find /I "CRL"') do (
  set PC=%%A
  echo !PC:\\=!>>"z.txt"
)

Open in new window

~bp
0
 
LVL 1

Author Closing Comment

by:ForLoop5
ID: 37017921
That worked great.  Thank you!
0
 
LVL 59

Expert Comment

by:Bill Prew
ID: 37018078
Very welcome, glad that helped.

~bp
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question