It works fine but when I execute this code on a normal User Account, i get the exception " Unable to read beyond the end of the stream" .
Im also aware that as a normal user, one will not be able to enable and disable network cards. I tried changing the settings in gpedit.msc bt it still doesnt work.
How do I grant permission to the user so that he wud b able to disable and enable the network card using the code below?
Expand|Select|Wrap|Line Numbers
- Dim strComputer As String
- Dim coladapters As Object
- strComputer = "."
- objWmiService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
- coladapters = objWmiService.Execquery("Select * from Win32_NetworkAdapter Where NetEnabled='false'")
- For Each Adapter In coladapters
- Adapter.enable()
- Next