Enable/Disable NIC from command line?

H

harryajh

I quite often just shut my laptop lid for a few hours and when
reopening it the NIC I was using to access the Internet is disabled!

Rather than re-enable via control panel etc... can I do it from the
command prompt e.g something like net start "Realtek RTL8139/810x
Family Fast Ethernet NIC"

I'm aware of the option to prevent vista disabling the device when in
sleep mode but want to try changing this setting if possible!

can it be done?

thanks

harry
 
A

Andrew McLaren

harryajh said:
Rather than re-enable via control panel etc... can I do it from the
command prompt e.g something like net start "Realtek RTL8139/810x
Family Fast Ethernet NIC"

Hi Harry

My first thought was that some variety of the "netsh" command, should do
this. But I can't work out the correct syntax (if any).

An alternative which will certainly work, but would require some small
effort on your part to set up, is to use the WMI Win32_NetworkAdapter Class
class. This class has an Enable method, which you could call in a short
VBScript. You'll find a sample scrip to enable an adapter, in the MSDN doco
for the method:

http://msdn2.microsoft.com/en-us/library/aa390385.aspx class.

Put the script in a file with a *.vbs extension, then run it at a command
prompt by typing the file name.

There may be other ways as well, but this should definitely work. Note that
you may need to open a command prompt "As Administrator" for this to work.

Hope it helps.
 
P

Paul Randall

Andrew McLaren said:
Hi Harry

My first thought was that some variety of the "netsh" command, should do
this. But I can't work out the correct syntax (if any).

An alternative which will certainly work, but would require some small
effort on your part to set up, is to use the WMI Win32_NetworkAdapter
Class class. This class has an Enable method, which you could call in a
short VBScript. You'll find a sample scrip to enable an adapter, in the
MSDN doco for the method:

http://msdn2.microsoft.com/en-us/library/aa390385.aspx class.

Put the script in a file with a *.vbs extension, then run it at a command
prompt by typing the file name.

There may be other ways as well, but this should definitely work. Note
that you may need to open a command prompt "As Administrator" for this to
work.

Hope it helps.

Posting to the newsgroup at microsoft.public.scripting.vbscript might lead
to such a script.

-Paul Randall
 
H

harryajh

Hi Harry

My first thought was that some variety of the "netsh" command, should do
this. But I can't work out the correct syntax (if any).

An alternative which will certainly work, but would require some small
effort on your part to set up, is to use the WMI Win32_NetworkAdapter Class
class. This class has an Enable method, which you could call in a short
VBScript. You'll find a sample scrip to enable an adapter, in the MSDN doco
for the method:

http://msdn2.microsoft.com/en-us/library/aa390385.aspxclass.

Put the script in a file with a *.vbs extension, then run it at a command
prompt by typing the file name.

There may be other ways as well, but this should definitely work. Note that
you may need to open a command prompt "As Administrator" for this to work.

Hope it helps.

many thanks for that andrew, will give it a go later & post back what
happens!
 
A

Adam Leinss

I quite often just shut my laptop lid for a few hours and when
reopening it the NIC I was using to access the Internet is disabled!

Rather than re-enable via control panel etc... can I do it from the
command prompt e.g something like net start "Realtek RTL8139/810x
Family Fast Ethernet NIC"

You can do it with devcon, try Googling "devcon"

Adam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top