Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to disable the local network card (only one in the computer) by using this command:

wmic path win32_networkadapter where index=7 call disable

return value is 5 (access denied). I don't know what the problem is.

The current user has admin rights (it is not actually the admin but has admin rights). Operating system is win7 professional.

When I activate the admin account and perform this command under this admin account everything works. But I don't wont to keep the real admin account enabled. runas isn't an option also.

It seems that I'm missing a specific right to run this command. Does anyone know what to do? Thank you!

share|improve this question

migrated from stackoverflow.com Jan 16 '13 at 9:01

This question came from our site for professional and enthusiast programmers.

2 Answers 2

Have you tried PowerShell?

Disable-NetAdapter -Name 'YourNic'

Here is an article I wrote on Enabling / Disabling NICs with PowerShell

Note: You need PowerShell v 3.0.

share|improve this answer

I had the same problem (solved). It is not enough the user to have admin rights. The most important is that you must 'run as administrator'. See the difference here. Right click the command prompt (or batch file) and choose 'Run as administrator'

This solved my problem with ReturnValue = 5;

And one more shortcuts - instead of

wmic path win32_networkadapter where index=7 call disable

you can use

wmic path win32_networkadapter where NetConnectionID="Wireless Network Connection" call disable

and for enable

wmic path win32_networkadapter where NetConnectionID="Wireless Network Connection" call enable
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.