Windows10 default gateway settings
■ Environment
OS: Windows10
Command prompt batch file

Error message

When you exit with a VPN software, the default gateway set with static IP disappears.
I made an inquiry to the company that produces this software, but it was answered that there was no solution.
■ Solution
Since there are hundreds of people, I want to create and deploy a batch file.
In order to set the default gateway to a batch file, it is necessary to set the IP address + subnet mask + default gateway.
Since the IP address has not disappeared, I think it is necessary to extract the IP address of each PC and set the default gateway.

Applicable source code

I tried to create the following as a beginner, but it didn't work. . I would appreciate your teaching.
■ Command * mask and gateway are described appropriately. All subnet masks are/24
Get REM IP address
for/F "tokens = 15"% i in ('ipconfig ^ | find "IPv4 address"') do @set MYIP =% i
REM IP address setting
netsh interface ipv4 set add name = "Ethernet" source = static addr = "% MYIP%" mask = "" gateway = "" gwmetric = 1

  • Answer # 1

    Assuming you are writing as is,

    % iis input from the command line, and%% iwhen writing to a batch file.

    The commandset MYIP = the environment variableMYIP space.
    If you want to set1.1.1.1to the environment variableMYIP,set MYIP =
    (Environment variable names can contain spaces and some symbols)