Sign in to follow this  
Followers 0
Joel

Need help with OS Environment problem

7 posts in this topic

#1 ·  Posted (edited)

Going to just place all of the code in and you can compile it to see the problem. The application I wrote is a utility that I plan on using at work. It makes up a lot of special handling events that I can use at work.

However, I combined a script that another user placed in because I liked the network adapter functionality. However, the network adapters show up fine on Win2k OS but not on WinXP OS. Can someone see where the problem is surfacing?

Here's the entire code and I'll follow it with highlights of the problem code:

Have to re-edit because of the length of code.. one moment.

Here's the function that is having the problem:

Func loadup()
   RunWait(@ComSpec & " /c " & "IPCONFIG.EXE /all" & " > " & "IPINFO.TXT", @MyDocumentsDir, @SW_HIDE)
   _FileReadToArray(@MyDocumentsDir & "\IPINFO.TXT", $temp)
   RunWait(@ComSpec & " /c " & "DEL.EXE IPINFO.TXT", @MyDocumentsDir, @SW_HIDE)
  ;$temp holds all IP info in a text array
   $arraysize = UBound($temp)
   
   $arraysize = $arraysize - 1
   $count = 0;set up counter for other arrays
   $adaptercount = 0;setup counter for # of adapters
   For $n = 0 To $arraysize
      $temp[$n] = StringStripWS($temp[$n], 4)
     ;locate the machine's name for display
      $result = StringInStr($temp[$n], "Host Name")
      If $result <> 0 Then
         $machinename = StringStripCR(StringMid($temp[$n], 37))
      EndIf
     ;process adapter info  1st drop to next line
      $result = StringInStr($temp[$n], "Description")
      If $result = 0 Then
         ContinueLoop
      Else
         $adaptercount = $adaptercount + 1; add to adapter count
         
         $adapter[$count][0] = StringStripCR(StringMid($temp[$n - 3], 18));connection name
         $lengthtemp = StringLen($adapter[$count][0])
         $adapter[$count][0] = StringLeft($adapter[$count][0], $lengthtemp - 1)
        ;msgbox (0, "", $adapter[$count][0])
         
         $adapter[$count][1] = StringStripCR(StringMid($temp[$n], 38)) ;adapter name
         $adapter[$count][2] = StringStripCR(StringMid($temp[$n + 1], 38)) ; adpater mac address
         $adapter[$count][3] = StringStripCR(StringMid($temp[$n + 2], 38)); DHCP enabled yes/no
         If $adapter[$count][3] = "Yes" Then
           ;skip auto configure line for DHCP enabled
            
            $adapter[$count][4] = StringStripCR(StringMid($temp[$n + 4], 38)) ; adapter IP address
            $adapter[$count][7] = StringStripCR(StringMid($temp[$n + 7], 38))  ;adapter DHCP Server
            $adapter[$count][5] = StringStripCR(StringMid($temp[$n + 5], 38))  ;adapter subnet mask
            $adapter[$count][6] = StringStripCR(StringMid($temp[$n + 6], 38))  ;adapter gateway
            $adapter[$count][8] = StringStripCR(StringMid($temp[$n + 8], 38))  ;adapter DNS Server
           ;$n= $n +1
           ;not DHCP is the next stuff
         Else
            $adapter[$count][4] = StringStripCR(StringMid($temp[$n + 3], 38))  ;adapter IP address if not DHCP
            $adapter[$count][7] = "None" ;NO DHCP SERVER
            $adapter[$count][5] = StringStripCR(StringMid($temp[$n + 4], 38))  ;adapter subnet mask
            $adapter[$count][6] = StringStripCR(StringMid($temp[$n + 5], 38))  ;adapter gateway
            If $n + 6 <= $arraysize Then
              ;assume static IP has DNS server
               $adapter[$count][8] = StringStripCR(StringMid($temp[$n + 6], 38))  ;adapter DNS Server
            EndIf
         EndIf
         
         $count = $count + 1
      EndIf
   Next
EndFunc  ;==>loadup
Edited by Joel

[font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font]

Share this post


Link to post
Share on other sites



When using this function on a Win2k machine, the drop down display for adapter shows Adapter and once you click the drop down, it shows the correct NIC card.

When using this function on a WinXP machine, the drop down display for adapter shows Adapter and nothing happens when you click the drop down. So, it's not finding the adapter information on WinXP.


[font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Does your IPINFO.TXT file have the same content on both versions of Windows? You can comment-out the line that deletes the file to see...

Edited by DaveF

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

Does your IPINFO.TXT file have the same content on both versions of Windows? You can comment-out the line that deletes the file to see...

<{POST_SNAPBACK}>

That's a great idea. My primary office environment is Win2k but there are those in other offices with WinXP.

I'll test the script on my WinXP at home and see what happens.


[font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Oh and by the way, I finally found the original thread where the network portion of my script is posted. Once again, I did not create the original network script but it was such a great idea, I had to include it in my GUI app.

http://www.autoitscript.com/forum/index.ph...topic=10242&hl=

Edited by Joel

[font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font]

Share this post


Link to post
Share on other sites

My guess is that the win2k and winXP output the info from ipconfig slightly differently

you may be able to overcome this by checking the OS version and parsing the text differently based on that

That said... the hardest thing I found (hardware side) to detect is the nic...

actually i could fnd it easy... but parsing it to just the nic name is difficult because of slight inconsistancies between computers

$objWMIService = objget("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

$colNIC = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapter")

For $object in $colNIC
    $PcInfo = $pcinfo & $object.name & @CRLF
Next

msgbox(48, "NIC", $pcinfo)

you might find that output is more regular throughout OS's


Share this post


Link to post
Share on other sites

If you still want to find the nic using the command line you can do it using this

ipconfig /all | find "description"

That will give you just the description of the nic

red

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0