Zohar

[Closed] How to Start and Stop a Network Connection?

19 posts in this topic

#1 ·  Posted (edited)

Hi

 

I am using Windows XP SP3,

and I have a Network Connection called "Local Area Network" that represents my Ethernet NIC.

How can I Start and Stop this connection, via AutoIt?

 

Thank you

Edited by Zohar

Share this post


Link to post
Share on other sites



 I've got an old thread with a script that may work with Windows XP still.  You are welcome to check it out to get some ideas.
https://www.autoitscript.com/forum/topic/52886-quicknic/

I believe you can also use the netsh command line utility to enable and/or disable a network interface.
 

Also, just a comment...Windows XP? 
*shivers  It's Highly vulnerable. 
nothing personal....just the computer security side of me freaking out

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thank you spudw2k

 

In addition to the vbScript, are there other options?

The Shell option doesn't work, because it seems it accepts Enabling/Disabling all network connections except the LAN one..

Edited by Zohar

Share this post


Link to post
Share on other sites

Thank you all :)

Share this post


Link to post
Share on other sites

here another way using "netsh":


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites
Run(@ComSpec & ' /c ' & 'netsh interface set interface name="local area connection" admin=disable')
Run(@ComSpec & ' /c ' & 'netsh interface set interface name="local area connection" admin=enable')

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thank you, but as written before,

the netsh option works on all items except the "Local Area Connection" item..

(it also writes it in the help for netsh)

 

I don't know why they decided to exclude the "Local Area Network" item from all the rest..

 

See this screenshot:

http://s1.postimg.org/854xb8t3j/netsh.png

Edited by Zohar

Share this post


Link to post
Share on other sites

in your original post you asked to enable/disable the nic called "Local Area Network"

did you try the code I posted at all?

Share this post


Link to post
Share on other sites

did you try the code I posted at all?

Of course

 

And it doesn't work, for the reason written in the screenshot I supplied in the last post..

 

Share this post


Link to post
Share on other sites

Also, you can use my Network configuration UDF : https://www.autoitscript.com/forum/topic/155539-network-configuration-udf/

#RequireAdmin

#Include "network.au3"

_DisableNetAdapter("Local Area Network")
; or
_EnableNetAdapter("Local Area Network")

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

you only ran "netsh interface set interface"
 

try running (copy as is)

netsh interface set interface name="local area connection" admin=disable

Capture.PNG

Edited by pcjunki

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

you only ran "netsh interface set interface"

No, I ran both commands :)

The shorter one was just to show what the help says, regarding not allowing changing the state of the LAN connection, for some reason that they have..

Here's the full command's result:

full.png

 

jguinch:
Thank you very much, interesting to find another method..

Edited by Zohar

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

... could you try this:

within a cmd prompt run as administrator type:

netsh interface show interface

above command should show you the exact name of your interface(s)

now type this command:

netsh interface set interface "Local Area Network" disabled

where the name of the interface must be exactly like shown in previous show interface command.

(in your command in post #13 you typed disable instead of disabled (you missed the last d)

Edited by Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

... could you try this:

within a cmd prompt run as administrator type:

netsh interface show interface

above command should show you the exact name of your interface(s)

now type this command:

netsh interface set interface "Local Area Network" disabled

where the name of the interface must be exactly like shown in previous show interface command.

(in your command in post #13 you typed disable instead of disabled (you missed the last d)

Regarding the interface names - yes I am complately aware of it, and I used the correct name.

If I try to write an incorrect name, I get

"An interface with this name is not registered with the router."

 

And If I try with the correct name, then it simply shows me the help again.

(probably to remind me that the LAN interface cannot be worked on - see the screenshot:  http://s1.postimg.org/854xb8t3j/netsh.png )

 

Also, I tried again with disabled, and no change unfortunately..

 

The netsh commands definitely work, I've tried them before on windows 10 and windows 7.

Maybe this exclusion of the LAN interface is only in Windows XP?

Because it really doesn't work here..

Share this post


Link to post
Share on other sites

lets see a screenshot when you run the command

netsh interface set interface name="local area connection" admin=disable

we need to see the cmd error

Share this post


Link to post
Share on other sites

dang... I didn't see that, I don't have a xp machine here at work, wonder if it's different, but I don't think so

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now