looking for command for disabling network adapter

shayo19

Beta member
Messages
5
Location
Israel
hi all

im looking for command that disable the network adapter (local area connection) for WIN XP, the win7 sytax does not fit,
i need just command line without the need to download any additional tools.

thanks, shay.
 
This should be the bit you'd want:

Code:
$Computer = "yourcomputernamehere"
$ConnectionName = "Local Area Connection"

$Networks = Get-WmiObject Win32_NetworkAdapter -ComputerName $Computer | ? {$_.NetConnectionID -match $ConnectionName}
   foreach ($Network in $Networks) {
    if($Enable) {
     $retval  = $Network.Enable()
     if($retval.ReturnValue -eq 0) {
      Write-host "Successfully enabled `"$($network.NetConnectionID)`" on $Computer"
     } else {
      write-host "Failed to enable `"$($network.NetConnectionID)`" on $Computer"
     }

Change the values for $Computer and $ConnectionName as you require.

Save that script as a .PS1 file and execute it. You'll need Microsoft's PowerShell installed already to run it.
 
First of all thank you for helping.
I cant install nothing on that computer i mentioned it at the first messege i need command that i can just type to the cmd directly,
Thanks.
 
Check if PowerShell is installed already or not - I know it was an optional update through Windows Update at one point for XP.

As for command line for XP...doesn't really seem to be any if "netsh" didn't work for you (I assume that's what you already tried).
Code:
netsh interface set interface “Local Area Connection” DISABLED

You'll have to use PowerShell or an external utility such as DevCon:
The DevCon command-line utility functions as an alternative to Device Manager
Blog of Thilina Piyasundara: Enable/Disable LAN interface by command prompt in Windows XP
 
The computer is in work network so he doesn't receive updates therefore i think that id didnt have the addition, ive tried the netsh command in several variations and it didn't succeed, as for devcon ive read about it but i cant add nothing to that computer, i now that it making it harder to deal with but im sure that there is away to work with the current terms.
Thanks again.
 
Back
Top Bottom