Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Vista Forums > General Discussion

Vista - Programming in CMD

Reply
 
Old 12-01-2008   #1 (permalink)


Vista Home Premium 32bit
 
 

Programming in CMD

Just to give you guys an idea of what I am trying to do. I want to make some simple programs using Command Prompt in Windows Vista. No, this is not a problem I am having with the OS. What I am trying to do, is to write a simple program that allows me to run IPCONFIG test for whatever computer this program is on. However, I need to know if there is a way to capture the IP address of the computer. So that it can be retrieved by the program and used to ping the local machine of the system?

My System SpecsSystem Spec
Old 12-02-2008   #2 (permalink)


Vista Ultimate x64 MAK, OpenSolaris 5, Gentoo 2008.1....
 
 

Re: Programming in CMD

There are third party apps that can do it, but not a really reliable way (AFAIK) o capture the *external* IP of the system.

Then again, I don't do this often, and I may be way off base....
My System SpecsSystem Spec
Old 12-02-2008   #3 (permalink)


Mojave Ultimate x64
 
 

Re: Programming in CMD

Quote  Quote: Originally Posted by Geekpower2000 View Post
Just to give you guys an idea of what I am trying to do. I want to make some simple programs using Command Prompt in Windows Vista. No, this is not a problem I am having with the OS. What I am trying to do, is to write a simple program that allows me to run IPCONFIG test for whatever computer this program is on. However, I need to know if there is a way to capture the IP address of the computer.
Use those code and save with the extension .vbs
Code:
strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colAdapters = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
 
n = 1
 
For Each objAdapter in colAdapters
   
   
 
   If Not IsNull(objAdapter.IPAddress) Then
      For i = 0 To UBound(objAdapter.IPAddress)
     WScript.Echo "  Your Local IP address is: " & objAdapter.IPAddress(i)
      Next
   End If
 
   n = n + 1
 
Next

Function WMIDateStringToDate(utcDate)
   WMIDateStringToDate = CDate(Mid(utcDate, 5, 2)  & "/" & _
       Mid(utcDate, 7, 2)  & "/" & _
           Left(utcDate, 4)    & " " & _
               Mid (utcDate, 9, 2) & ":" & _
                   Mid(utcDate, 11, 2) & ":" & _
                      Mid(utcDate, 13, 2)) 

End Function
Quote:
So that it can be retrieved by the program and used to ping the local machine of the system?
You comepletely lost me at this part.
My System SpecsSystem Spec
Old 12-02-2008   #4 (permalink)


Vista Home Premium 32bit
 
 

Re: Programming in CMD

As for where I lost you. There is a truncated version of the command prompt in Windows Vista. What I am trying to do is simply this.

When I start the program it runs the ip configuration test for you. So what you have is this. In the program it has a line of command that brings up your ip configuration information. Then grabs your IP from the local machine, and pings the IP address. So, it would look something lik this.

ipconfig /all
(program grabs the IP address of the local machine)
ping ooo.ooo.oo.o (program has pinged the IP address through the command prompt and pings it.)

I hope this makes things a little more clear. If I have lost you then I can attempt to tell you what it is.
My System SpecsSystem Spec
Old 12-02-2008   #5 (permalink)


Mojave Ultimate x64
 
 

Re: Programming in CMD

Ok this is what is confusing me, it sounds like you are running the program on a local machine and then trying to ping its own address.
My System SpecsSystem Spec
Old 12-02-2008   #6 (permalink)


Vista Home Premium 32bit
 
 

Re: Programming in CMD

Pretty much. I am trying to write a program that will grab the ip address as a variable, then ping that address automaticly.
My System SpecsSystem Spec
Old 12-02-2008   #7 (permalink)


Mojave Ultimate x64
 
 

Re: Programming in CMD

Well you could edit that script I pasted above, and then take a look here and add this code:

http://windowsitpro.com/article/arti...a-machine.html

Just mod that code to ping the returned value from the script from my previous post. If you get stuck let me know.

Just out of curiousity, why are you trying to ping the local IP address?
My System SpecsSystem Spec
Old 12-02-2008   #8 (permalink)


Vista Home Premium 32bit
 
 

Re: Programming in CMD

I am currantly a student at a private IT college. I am trying to do simple programming as it relates to a class I am currantly taking.
What I wanted to do was to make a program that runs an IP test to test home network connections, then gives you the simple information that any tech would use to diagnose network issues. Including ping rate, timing issues, DNS resolution issues, and so forth, ect ect.
My System SpecsSystem Spec
Old 12-02-2008   #9 (permalink)


Vista Ultimate x64 MAK, OpenSolaris 5, Gentoo 2008.1....
 
 

Re: Programming in CMD

You might could look into Windows Power Shell - it is much more robust and will probably suit your needs.
My System SpecsSystem Spec
Old 12-03-2008   #10 (permalink)


Vista Home Premium 32bit
 
 

Re: Programming in CMD

I will look into that.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
64 bit programming General Discussion
New to programming .NET General
c programming on 64bit Microsoft Office
Team programming .NET General
TV Programming Guide Off Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46