Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using the net view command. It displays the users on the network in big and ugly UPPERCASE letters and has columns etc., for example:

Server Name            Remark    
-------------------------------------------------------------------------------
\\ADRIAN-PC
\\MARK-PC

The command completed successfully.

Is there a way for me just to display the computer names on the network?

-Adrian
-Mark

I'd like to have the output without the lines and columns. Maybe with a findstr command.

share|improve this question
6  
What do you need that for? Notice that not all computers will have names like SOMEONE'S-PC. –  gronostaj Mar 24 '13 at 17:19

2 Answers 2

(for /f %a in ('net view ^| findstr/b \\\\') do @echo %a)

You cannot (or should not) remove the -PC suffix, since you are not listing usernames – you are listing computer names, and the suffix is part of the computer name.

share|improve this answer
    
Sorry We South Africans spell "welldone" with 2 L's. Thanks for the code I'll test it out now! :) –  Adrianvdh Mar 24 '13 at 18:28
    
So would it work if I had 5 users on the network? –  Adrianvdh Mar 24 '13 at 18:37
    
And is it possible for me to save it into a varible i.e for /f %%i in ('net view^|findstr /b \\') do set networkuser=%%i –  Adrianvdh Mar 24 '13 at 18:44
    
Or if there are no users on the network. echo NO USERS FOUND –  Adrianvdh Mar 24 '13 at 19:21
2  
It doesn't list users. It lists computers. –  grawity Mar 24 '13 at 20:00

Net View displays domain/workgroup resources, i.e server and PC resources. It doesn’t give an accurate overview of machines on the network as that’s not it’s complete role. You need to use ARP –a to get this and translate them to their hostnames.

share|improve this answer
    
I don't think arp -a is the same (even if I pipe the IP addresses into an ip->hostname translator like nslookup), it only shows me about 10 IP addresses, and I know there are about 30 machines on the network right now (that show up in "My Network Places" anyway, probably even a few more than that). -- It's an NT domain if it matters/makes more tools available. -- How do I get a list of host names (or even IPs) of all the machines on the current network? (Or even subnet for that matter.) –  BrainSlugs83 Oct 20 at 20:53
    
You either write a script that will be all the possible hosts on the network, use ARP but as you can see it's limited to the amount of hosts the computer actually knows about at that time. Or you connect to the gateways and see their connections/DHCP bindings etc –  Ben Lavender Oct 26 at 15:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.