|
-
Dec 12th, 2007, 06:37 PM
#1
Thread Starter
Addicted Member
[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}
-
Dec 14th, 2007, 04:28 PM
#2
Thread Starter
Addicted Member
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}
-
Dec 15th, 2007, 11:42 AM
#3
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Dec 20th, 2007, 01:12 PM
#4
Thread Starter
Addicted Member
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}
-
Dec 20th, 2007, 01:55 PM
#5
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|