SmackAHobo Posted July 15, 2010 Author Share Posted July 15, 2010 Hey guys,I've been searching the net and i'm having a difficult time finding an answer to my question.I'm trying to get the Ip's of all computers on my network through CMD and I can't figure out the commands for it. There are quite a few computers (120) aswell so i'd like to have all there Ip's automatically put into a txt file. Is this possible through CMD?If not, how would you do this in VB6? Link to comment Share on other sites More sharing options...
Anna Comnena Posted July 15, 2010 Share Posted July 15, 2010 Talk to your network administrator. Link to comment Share on other sites More sharing options...
SmackAHobo Posted July 15, 2010 Author Share Posted July 15, 2010 My network Admin wouldn't like what I'm doing (Setting up games). Link to comment Share on other sites More sharing options...
Gwen Posted July 15, 2010 Share Posted July 15, 2010 most likely your network is on dhcp which gives out ip leases so they change every so often. so having a list wouldnt do much good.If you network admin wont like what you are doing, then why are you risking getting caught installing games. If your IT person is competent I'm sure they will find you.You could try to ping every ip in your network range. Link to comment Share on other sites More sharing options...
SmackAHobo Posted July 16, 2010 Author Share Posted July 16, 2010 As i said, there are quite a few computers on the network and I really don't want to ping everyone of them. Does anyone know a command that can do this automatically or maybe some VB code that can do it? Link to comment Share on other sites More sharing options...
Godlord Posted July 16, 2010 Share Posted July 16, 2010 @SmackAHobo:> As I said, there are quite a few computers on the network and I really don't want to ping everyone of them. Does anyone know a command that can do this automatically or maybe some VB code that can do it?There isn't any. Only your router, switch or hub knows what computers are connected, and it only knows that when they're active. So the only way is pinging really.Regards, Stephan. Link to comment Share on other sites More sharing options...
AeroEBrown Posted July 16, 2010 Share Posted July 16, 2010 @Stephan:> @SmackAHobo:> > > As I said, there are quite a few computers on the network and I really don't want to ping everyone of them. Does anyone know a command that can do this automatically or maybe some VB code that can do it?> > There isn't any. Only your router, switch or hub knows what computers are connected, and it only knows that when they're active. So the only way is pinging really.> > Regards,> Stephan.Do a ping loop as Stephan said.I.e. (not VB I know, it's C#, but w/e.)```for (int h = 0; h <= 255; h++){for (int f = 0; f <= 255; f++){// Ping code for 192.168.h.f}}```That is something you could try.http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.aspxThanks,Aero/EBrown Link to comment Share on other sites More sharing options...
SmackAHobo Posted July 16, 2010 Author Share Posted July 16, 2010 If I use the "net view" command it gives me all the computers on the network. Is there no way to take all those names, export them to a txt file and then have VB ping each one automatically? I should add that not all the computers have the same IP's, eg they're not all 192.168.1.0, some have IP's like 10.34.8.xx ect. Link to comment Share on other sites More sharing options...
AeroEBrown Posted July 16, 2010 Share Posted July 16, 2010 @SmackAHobo:> If I use the "net view" command it gives me all the computers on the network. Is there no way to take all those names, export them to a txt file and then have VB ping each one automatically? I should add that not all the computers have the same IP's, eg they're not all 192.168.1.0, some have IP's like 10.34.8.xx ect.You can modify all my stuff as needed.You should look into StreamWriter. (http://msdn.microsoft.com/en-us/library/system.io.streamwriter.aspx)Thanks,Aero/EBrown Link to comment Share on other sites More sharing options...
SmackAHobo Posted July 16, 2010 Author Share Posted July 16, 2010 @Aero/EBrown:> You can modify all my stuff as needed.Thanks, but what stuff is that exactly?Also writing stuff to a txt file is no worries, its actually just doing all the cmd stuff through vb thats the problem. Link to comment Share on other sites More sharing options...
AeroEBrown Posted July 16, 2010 Share Posted July 16, 2010 @SmackAHobo:> @Aero/EBrown:> > > You can modify all my stuff as needed.> > Thanks, but what stuff is that exactly?> Also writing stuff to a txt file is no worries, its actually just doing all the cmd stuff through vb thats the problem.The loop I wrote. Though there are different ways to do it.What I would do, is find all the generic (I.e. x.x.*.*, where we find the x's) manually, and write a loop to adapt to that, and check if the computer responds. If it responds, write the IP to the text file.I don't know any other ways to do it. Except with a program accepting connections to add them to the file.Thanks,Aero/EBrown Link to comment Share on other sites More sharing options...
SmackAHobo Posted July 16, 2010 Author Share Posted July 16, 2010 Ok i've got somethings working at the moment, just wondering how you get text from command prompt? The commands work, but I want to print the data too a text box on the screen.Here's the code:Dim sYourCommand As String'sYourCommand = "\\networkfolder\project\testfile.txt"Shell("cmd /c " & "IpConfig") Link to comment Share on other sites More sharing options...
AeroEBrown Posted July 16, 2010 Share Posted July 16, 2010 @SmackAHobo:> Ok I've got somethings working at the moment, just wondering how you get text from command prompt? The commands work, but I want to print the data too a text box on the screen.> Here's the code:> Dim sYourCommand As String> 'sYourCommand = "\\networkfolder\project\testfile.txt"> Shell("cmd /c " & "IpConfig")Why not store the shell in a variable?```Dim shellResults As StringshellResults = Shell("cmd /c " & "IpConfig")textBox.Text += shellResults```Thanks,Aero/EBrown Link to comment Share on other sites More sharing options...
SmackAHobo Posted July 16, 2010 Author Share Posted July 16, 2010 Your a legend, thank you. I thought it would have been a more complex command for that….I was looking to much into it. Link to comment Share on other sites More sharing options...
SmackAHobo Posted July 16, 2010 Author Share Posted July 16, 2010 Actually, when I responded in the last post I hadn't tested it. Now that i've tested it….... it doesn't work. Whats wrong with it? Link to comment Share on other sites More sharing options...
AeroEBrown Posted July 16, 2010 Share Posted July 16, 2010 @SmackAHobo:> Actually, when I responded in the last post I hadn't tested it. Now that I've tested it….... it doesn't work. Whats wrong with it?I am not a genius at VB.NET, so there could be some syntax error I forgot.```Dim shellResults As StringshellResults = Shell("cmd /c " & "IpConfig")textBox.Text += shellResults```You'll need to replace```textBox.Text```with your text box, or rich text box.Thanks,Aero/EBrown Link to comment Share on other sites More sharing options...
Gwen Posted July 16, 2010 Share Posted July 16, 2010 here run this in command depending on which ip range you are using.FOR /L %A IN (1,1,255) DO ping -n 1 192.168.0.%A >> test0.txtFOR /L %A IN (1,1,255) DO ping -n 1 192.168.1.%A >> test1.txtFOR /L %A IN (1,1,255) DO ping -n 1 10.100.1.%A >> test10.txtThis will ping every ip from .1 to .255 in that range and put it in a txt file.I dont really do batch programing so I dont know how to do an if to only display replies.You will get a text file in whatever directory you run this command with the following results in it so you will need to do your own regular expressions to get the lines with reply….Pinging 10.100.1.107 with 32 bytes of data:Request timed out.Ping statistics for 10.100.1.107: Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),Pinging 10.100.1.108 with 32 bytes of data:Reply from 10.100.1.108: bytes=32 time<1ms TTL=128Ping statistics for 10.100.1.108: Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now