Results 1 to 5 of 5

Thread: [RESOLVED] Problems with Win32_NetworkAdapterConfiguration in Vista

  1. #1

    Thread Starter
    Addicted Member kzatu's Avatar
    Join Date
    Aug 2003
    Location
    Nevada
    Posts
    148

    Resolved [RESOLVED] Problems with Win32_NetworkAdapterConfiguration in Vista

    I have used the code on the following page in a program I wrote. WMI Tasks: Networking

    It works fine in XP but when I tested the code in Vista it doesn't work. For example, the ReleaseDHCPLease function (shown below) returns error code 83 which is "Unable to Release". Every MSDN article I've read regarding this code and the other Win32_Network AdapterConfiguration functions says it works in Vista. What am I missing?

    Code:
        strComputer = "."
        Set objWMIService = GetObject( _
            "winmgmts:\\" & strComputer & "\root\cimv2")
        Set colNetCards = objWMIService.ExecQuery _
            ("Select * From Win32_NetworkAdapterConfiguration " _
                & "Where IPEnabled = True")
        For Each objNetCard In colNetCards
            Debug.Print objNetCard.ReleaseDHCPLease
        Next
    Changes are not permanent, but change is. {Neil Peart}

  2. #2

    Thread Starter
    Addicted Member kzatu's Avatar
    Join Date
    Aug 2003
    Location
    Nevada
    Posts
    148

    Re: Problems with Win32_NetworkAdapterConfiguration in Vista

    I've been troubleshooting this and I believe it does not work because the code is not running with elevated priviledges in Vista. I've been told to look at something called a manifest (which I have never heard of before now). My quick research on these manifests looks like they are for XP and that they are for making your application look like the XP theme/style. How could this make my program run with elevated priviledges in Vista?

    Am I on the right track?
    Changes are not permanent, but change is. {Neil Peart}

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Problems with Win32_NetworkAdapterConfiguration in Vista

    This is an exeample of a manifest file that will request the elevation of permissions.

    A manifest file can do many other things then just link the common controls for xp theming.

    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
        <assemblyIdentity version="1.0.0.0"
    	processorArchitecture="X86"
    	name="EXENAME"
    	type="win32"/> 
    <description>elevate execution level</description> 
       <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
          <security>
             <requestedPrivileges>
                <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
             </requestedPrivileges>
          </security>
       </trustInfo>
    </assembly>
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Addicted Member kzatu's Avatar
    Join Date
    Aug 2003
    Location
    Nevada
    Posts
    148

    Resolved Re: Problems with Win32_NetworkAdapterConfiguration in Vista

    Okay. I've got this fixed. The problem is that Vista does require elevated admin priviledges to use the Win32_NetworkAdapterConfiguration calls but only the ones that make changes to your network settings; though it can read the network settings without the elevated priviledge.

    Thanks to RobDog888's last post, I was able to solve this problem. So here is what I did.

    First I copied RobDog888's manifest code above and pasted it into a file which I called myfile.exe.manifest.

    Next I compiled by VB6 program and called it myfile.exe.

    Then I downloaded MT.exe from Software Development Kit for Windows Vista™ and .NET Framework 3.0 Runtime Components here. This was a huge install that took a long time just to simply get the MT.exe file.

    Finally I moved all three files (the manifest, myfile.exe, and MT.exe) into the same folder and ran this command line,
    Code:
    mt -nologo -manifest myfile.exe.manifest -outputresource:myfile.exe;1
    That embedded the manifest into my myfile.exe. Now each time I run myfile.exe, Vista asks me to elevate priviledges and all the Win32_NetworkAdapterConfiguration works. I also tested the new myfile.exe on XP and I found no problems there either.
    Changes are not permanent, but change is. {Neil Peart}

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] Problems with Win32_NetworkAdapterConfiguration in Vista

    You can embed your manifest file into your vb 6 exe withoutusing the mt utility. There are other tricks you can use with resource files in VB 6 to embed the manifest file.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width