disable network adapter with wmic - access denied (Windows 7 Prof)

0

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!

manton

Posted 2013-01-16T07:23:12.837

Reputation:

Answers

1

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

Tzvetan Yakimov

Posted 2013-01-16T07:23:12.837

Reputation: 11

0

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.

Guy Thomas

Posted 2013-01-16T07:23:12.837

Reputation: 3 160