tags:

views:

330

answers:

1

My network card is rubbish and until I get a new one I need a quickfix. My idea was to have a program ping my router and when the ping failed 3 or 4 times, it would reset the network adaptor for my wifi card, however I do not know the command line commands to do this!

I found the following in a stackoverflow question:

$adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like "*Wireless*"}
$adaptor.Disable()
$adaptor.Enable()

However to run this the script needs to be running under admin privileges and I do not know how to fix that without manually launchign powershell to execute the script

+2  A: 

This post shows how to elevate PowerShell scripts to Administrator access:

http://stackoverflow.com/questions/915482/elevate-powershell-scripts

To do it, you create a scheduled task (without a set schedule), and set it to run elevated. Then, give your users rights to execute that task. This blog post describes the process in more detail:

http://huddledmasses.org/vista-setuid-how-to-elevate-without-prompting/

In addition, here is a blog post that goes over the Win32_NetworkAdapter class, and how to use it in PowerShell, in detail:

Using PowerShell to Manage Network Interfaces and Windows Services http://rickgaribay.net/archive/2008/09/26/using-powershell-to-manage-network-interfaces-and-windows-services.aspx

Robert Harvey