Is it possible to disconnect the internet before running a test in AppVeyor build?

weerayuth_r's Avatar


01 Dec, 2020 06:36 AM

I have a test scenario to test an application when there is no internet connection.

Is it possible to disable the internet connection when running the test in Appveyor?

I have tried to add the following Powershell commands. However, it doesn't work. It's stuck in the first command.

  • ps: Get-NetAdapter | format-table
  • ps: Disable-NetAdapter -Name "Ethernet 4" -Confirm:$false

Note: image: Visual Studio 2019

  1. Support Staff 1 Posted by Feodor Fitsner on 02 Dec, 2020 04:38 AM

    Feodor Fitsner's Avatar

    Actually, you can perform the tests with VM disconnected from internet. The only trick here you should reboot VM after tests, so build agent could reconnect on boot:

    - ps: Get-NetAdapter | format-table
    - ps: Disable-NetAdapter -Name "Ethernet 4" -Confirm:$false
    - <your tests go here>
    - ps: Start-Sleep -s 5; Restart-Computer
    - ps: Start-Sleep -s 5
    - ps: <output or upload results>

    You will be able to print/push test results after reboot.

    Hope that helps.

    PS: Don't forget to enable adapter before reboot.

  2. 2 Posted by weerayuth_r on 04 Dec, 2020 03:45 AM

    weerayuth_r's Avatar

    Thanks Feodor for the suggestion. I will give it a try.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac