Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: On/Off Internet

  1. #1
    3 Star Lounger Not Brightest Bulb's Avatar
    Join Date
    Dec 2009
    Location
    Central IL
    Posts
    376
    Thanks
    69
    Thanked 4 Times in 4 Posts

    On/Off Internet

    It's been quite a while back when I got info on a couple batch files to turn wifi internet connections on and off.

    This was for wifi hardwired from tower to PC and they worked great. Last week I switched over to Frontier services that piggy backs on phone line. Big upward change in speed and consistency, only problem is I can disable the net but it won't turn back on. I have to reboot to get net back. Any ideas.

  2. #2
    Administrator
    Join Date
    Jun 2010
    Location
    Portugal
    Posts
    12,519
    Thanks
    152
    Thanked 1,398 Times in 1,221 Posts
    You mean disable your wifi client?
    Rui
    -------
    R4

  3. #3
    3 Star Lounger Not Brightest Bulb's Avatar
    Join Date
    Dec 2009
    Location
    Central IL
    Posts
    376
    Thanks
    69
    Thanked 4 Times in 4 Posts
    No, just turning internet on and off below are instructions I received here and they worked great.

    • Click Start. Enter "CMD" (without the quotes) in the Search Program and Files box
    • Right Click on the CMD prompt that appears at the top of the menu and select Run As Administrator
    • In the command window that opens enter the following code: "wmic nic get name, index" Without the quotes
    • Take a note of the index number of your network port.
    • Now Open Notepad (Start>Accessoroes>Notepad) and enter the text "wmic path win32_networkadapter where index=7 call disable" Without the quotes. Where XX is the index number you just noted.
    • Save this file on your desktop as a file called Internet off.bat
    • Create a copy of that file and edit it to contain the text "wmic path win32_networkadapter where index=7 call enable" Without the quotes. Where XX is the index number you noted earlier.
    • Save this copy of the file on your desktop called Internet on.bat

  4. #4
    Administrator
    Join Date
    Jun 2010
    Location
    Portugal
    Posts
    12,519
    Thanks
    152
    Thanked 1,398 Times in 1,221 Posts
    Sorry, I don't think I can help with that.
    Rui
    -------
    R4

  5. #5
    Lounge VIP
    Join Date
    Apr 2011
    Location
    Scotland
    Posts
    1,168
    Thanks
    44
    Thanked 134 Times in 115 Posts
    Do you mean this advice perchance

    Read through that thread from start to finsih to refresh the memory.

    What you need to do is identify the index number of the adapter you wish to enable and disable, then put that index number in to the wmi command inside the batch files previously created.

    So, to fix the batch files for the new adapter:

    • Click Start. Enter "CMD" (without the quotes) in the Search Program and Files box
    • Right Click on the CMD prompt that appears at the top of the menu and select Run As Administrator
    • In the command window that opens enter the following code: "wmic nic get name, index" Without the quotes


    Take a note of the index number of the network port you want to enable and disable. Last time it was 7, but this time it maybe something different.

    Now you need to edit the batch files to update them with that index number.

    Copy the two batch files to somewhere else to act as a backup first.

    Next, Right click on the Internet off.bat file and choose edit. This will open notepad and allow you to edit the file. Find the line that says "wmic path win32_networkadapter where index=XX call disable" Replace XX with the index number you just noted above

    Close Notepad and choose save.

    Then, Right click on the Internet on.bat file and choose edit. Find the line that says "wmic path win32_networkadapter where index=XX call enable" Replace XX with the index number you just noted above.

    Close Notepad and choose save.

    If you have correctly identified the adapter the updated batch files will enable and disable correctly again.
    In God we trust; all others must bring data.

    - William Edwards Deming. 1900 - 1993

  6. #6
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    NBB,

    This intrigued me so I though I'd investigate if I could do this with PowerShell so here's what I've cobbled together FWIW:
    Code:
    <# +-------------------------------------------+
       | Program Name: BackupImageList.ps1         |
       | Programmed by: ComputerMentor             |
       |           AKA: RetiredGeek                |
       | Created      : 11/21/2013                 |
       | Last Update  :                            |
       | Version No.  : 1.0                        |
       +-------------------------------------------+
    #>
    
    cls
    Write-Host "Network Information" -ForegroundColor Yellow
    Write-Host "___________________" -ForegroundColor Yellow
    Write-Host
    
    $colItems = Get-NetAdapter -Name *
    
    #$colItems | Get-Member
    
    
    $fmt = @{Expression={$_.Index };Label="ID";Width=2},
           @{Expression={ $_.Name};Label="Name";Width=35},
           @{Expression={$_.Status};Label="Status";Width=25}
    
    
      $colItems | Foreach-Object { $index = 0 } { [PSCustomObject] `
         @{ Index = $index; Name = $_.Name; Status = $_.Status}; $index++ } `
         | Format-Table $fmt 
      
    
     $NetWorkAdapter = Read-host 'Enter Adapter Number' 
    
     if ( $colItems[$NetworkAdapter].Status -eq 'Up' ) {
        Write-host "Disabling: " $colItems[$NetworkAdapter].name
        disable-NetAdapter -Name $colItems[$NetworkAdapter].name –Confirm:$false
     }
     Elseif ( $colItems[$NetworkAdapter].Status -eq 'Disabled' ) {
        Write-host "Enabling: " $colItems[$NetworkAdapter].name
        enable-NetAdapter -Name $colItems[$NetworkAdapter].name –Confirm:$false
     }
     Else {
        Write-Host "No action taken for " `
                   $colItems[$NetworkAdapter].name "Status: " `
                   $colItems[$NetworkAdapter].status
     }
      read-host 'Press any key to continue...'
    Copy the code above into a notepad then save as "NicOnOFF.PS1" {keep the quotes!}.
    Setup a shortcut as follows:
    Target: %windir%\system32\WindowsPowerShell\v1.0\PowerShel l.exe G:\BEKDocs\Scripts\NicOnOFF.ps1
    Note: adjust the drive and path for the .ps1 file based on where you saved it in the step above!
    Name: What ever you want
    Under the Shortcut Tab -> Advanced... button check Run as administrator.
    Save the shortcut to a convenient location.
    Double-Click shortcut to run and click on the UAC prompt {You can get rid of the UAC prompt by setting up a scheduled task to run the program.
    NicOnOff.JPG
    The program will show you the current status of your Network Interface Cards (NICs).
    Simply select the desired card number and the program will toggle its status. Enabled to Disabled and visa-versa.
    Note: if the status is Disconnected the program will take no action and inform you to this situation.

    I had fun figuring this out and I hope someone besides me finds it useful. HTH
    Last edited by RetiredGeek; 2013-11-21 at 23:35.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  7. The Following User Says Thank You to RetiredGeek For This Useful Post:

    Medico (2013-11-22)

  8. #7
    Plutonium Lounger Medico's Avatar
    Join Date
    Dec 2009
    Location
    USA
    Posts
    12,631
    Thanks
    161
    Thanked 936 Times in 856 Posts
    I most likely will not use this, but as you say it is very intriguing. You are a very "fart smella" as my grandson would say!

    Cheers.
    BACKUP...BACKUP...BACKUP
    Have a Great Day! Ted


    Sony Vaio Laptop, 2.53 GHz Duo Core Intel CPU, 8 GB RAM, 320 GB HD
    Win 8 Pro (64 Bit), IE 10 (64 Bit)


    Complete PC Specs: By Speccy

  9. #8
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Medico,

    Have you been talking to my wife?
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  10. #9
    Plutonium Lounger Medico's Avatar
    Join Date
    Dec 2009
    Location
    USA
    Posts
    12,631
    Thanks
    161
    Thanked 936 Times in 856 Posts
    No sir!
    BACKUP...BACKUP...BACKUP
    Have a Great Day! Ted


    Sony Vaio Laptop, 2.53 GHz Duo Core Intel CPU, 8 GB RAM, 320 GB HD
    Win 8 Pro (64 Bit), IE 10 (64 Bit)


    Complete PC Specs: By Speccy

  11. #10
    3 Star Lounger Not Brightest Bulb's Avatar
    Join Date
    Dec 2009
    Location
    Central IL
    Posts
    376
    Thanks
    69
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Tinto Tech View Post
    Do you mean this advice perchance

    Read through that thread from start to finsih to refresh the memory.

    What you need to do is identify the index number of the adapter you wish to enable and disable, then put that index number in to the wmi command inside the batch files previously created.

    So, to fix the batch files for the new adapter:

    • Click Start. Enter "CMD" (without the quotes) in the Search Program and Files box
    • Right Click on the CMD prompt that appears at the top of the menu and select Run As Administrator
    • In the command window that opens enter the following code: "wmic nic get name, index" Without the quotes


    Take a note of the index number of the network port you want to enable and disable. Last time it was 7, but this time it maybe something different.

    Now you need to edit the batch files to update them with that index number.

    Copy the two batch files to somewhere else to act as a backup first.

    Next, Right click on the Internet off.bat file and choose edit. This will open notepad and allow you to edit the file. Find the line that says "wmic path win32_networkadapter where index=XX call disable" Replace XX with the index number you just noted above

    Close Notepad and choose save.

    Then, Right click on the Internet on.bat file and choose edit. Find the line that says "wmic path win32_networkadapter where index=XX call enable" Replace XX with the index number you just noted above.

    Close Notepad and choose save.

    If you have correctly identified the adapter the updated batch files will enable and disable correctly again.
    Thank you, I will give this a try cause the 1st one worked and this adjustment hopefully will do the repair/renew program.

  12. #11
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Hey Y'all,

    Here's version 2. This version is "Windowed" i.e. it uses Forms/List Boxes/Message Boxes and your Mouse!

    Enable-Disable-NICs.zip
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  13. #12
    3 Star Lounger Not Brightest Bulb's Avatar
    Join Date
    Dec 2009
    Location
    Central IL
    Posts
    376
    Thanks
    69
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by RetiredGeek View Post
    Hey Y'all,

    Here's version 2. This version is "Windowed" i.e. it uses Forms/List Boxes/Message Boxes and your Mouse!

    Enable-Disable-NICs.zip
    Clicked on link nothing happened.

    Oh my, I'm expecting to go to a webpage and guess what, I downloaded the zip files. I blame you Retired Geek, you forgot the caliber of the Bulb. I need road maps for everything

    I'm hoping this is a simple install etc.

    Ok, I clicked on it and I get a notepad which is way over my payscale. Do not have a clue as to what to do with it, HELP!!!!!!!
    Last edited by Not Brightest Bulb; 2013-11-23 at 08:45.

  14. #13
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    NBB,

    Sorry, I should have included installation instructions as most people don't use powershell so here goes:

    1. Download the ZIp file.
    2. Extract the single file to a directory in your Documents folder { I use Scripts }
    3. Start PowerShell {Win 7 (or win 8 with a Start Button replacement) Click on Orb type PowerShell in the search box}
      {Win 8.x from the Start Screen start typing PowerShell then click on Windows PowerShell (2nd item in list..you do NOT want the ISE version)}.
    4. Right-Click on Windows PowerShell in the search resulty and click on Run as Administrator.
    5. Type this command into the PowerShell window: Set-ExecutionPolicy Unrestricted {Enter Key}
    6. Answer Y to the prompt to confirm.
    7. Note: the above command only needs to be entered ONCE!
    8. Type: get-executionpolicy {Enter Key} this command should reply with unrestricted confirming you executed the above command correctly.
    9. Type: Exit {Enter Key} you should be back at the desktop now.
    10. Right-Click on the Desktop and select New->Shortcut
    11. In the location box type: %windir%\System32\WindowsPowerShell\v1.0\powershel l.exe d:\path\Enable-Disable-NICs.ps1 (changing d:\path as appropriate for your system).
    12. Click: Next
    13. In the Name Shortcut box type a name of your choosing.
    14. Click: Finish
    15. Right-Click on the new Powershell Icon on your desktop and select properties.
    16. On the Shortcut tab click the Advanced button.
    17. Check the Run as administrator check box.
    18. Click: OK
    19. Click: OK
    20. Double click the Icon to run the program.


    Note: While testing this on my Win-7 machine I found out that it will NOT run with PowerShell version 3.0. You have to upgrade your PS to ver 4.0 {4.0 comes w/Win 8.x}. The upgrade if a free download from MS. You can test your PowerShell version by typing $psversiontable in the PowerShell window.

    Note2: And upon further investigation the Get-NetAdapter cmd-let isn't present/working in Win 7 at all! So looks like this is a Windows 8.1 function ... see post below!
    Last edited by RetiredGeek; 2013-11-23 at 14:05.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  15. #14
    3 Star Lounger Not Brightest Bulb's Avatar
    Join Date
    Dec 2009
    Location
    Central IL
    Posts
    376
    Thanks
    69
    Thanked 4 Times in 4 Posts
    Thank you for the info but there is no way, if you are going nuts I know I will be lost to wander around forever in PC land.

  16. #15
    3 Star Lounger Not Brightest Bulb's Avatar
    Join Date
    Dec 2009
    Location
    Central IL
    Posts
    376
    Thanks
    69
    Thanked 4 Times in 4 Posts
    internet ports.PNG

    I hope the pic turns out but I do not have a clue as to what port should be edited. When I went to edit the port was indeed already marked as 7.

    The good news is that I actually got into batch files again cause it's been a while and I've forgotten completely how I did everything the 1st time.
    Last edited by Not Brightest Bulb; 2013-11-23 at 12:39.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •