Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch giving invalid address parameter  (Read 6465 times)

0 Members and 1 Guest are viewing this topic.

dark0Prince

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Windows 10
    Batch giving invalid address parameter
    « on: July 13, 2017, 01:57:39 PM »
    I'm getting this error in bold and I'm new to batch code. It should change my static IP based on the option I chose A,B or C. "Invalid address parameter (1). It should be a valid IPv4 address."

    Here is my code below.

    Code: [Select]
    @echo off
    echo Choose:
    echo [A] Set ABQ Static IP
    echo [B] Set GJ Static IP
    echo [B] Set PB Static IP
    echo.
    :choice
    SET /P C=[A,B,C]?
    for %%? in (A) do if /I "%C%"=="%%?" goto A
    for %%? in (B) do if /I "%C%"=="%%?" goto GJ
    for %%? in (C) do if /I "%C%"=="%%?" goto PB
     
    goto choice
    :A
    @echo off
    echo "Please enter Static IP Address Information"
    echo "Static IP Address:"
    set /p IP_Addr=10.1.4.53

    echo "Default Gateway:"
    set /p D_Gate=10.1.4.1

    echo "Subnet Mask:"
    set /p Sub_Mask=255.255.255.0

    echo "Setting Static IP Information"
    netsh interface ip set address "Local Area Connection" static %IP_Addr% %Sub_Mask% %D_Gate% 1
    netsh int ip show config
    pause
    goto end

    :GJ
    @echo off
    echo "Please enter Static IP Address Information"
    echo "Static IP Address:"
    set /p IP_Addr=10.1.2.53

    echo "Default Gateway:"
    set /p D_Gate=10.1.2.1

    echo "Subnet Mask:"
    set /p Sub_Mask=255.255.255.0

    echo "Setting Static IP Information"
    netsh interface ip set address "Local Area Connection" static %IP_Addr% %Sub_Mask% %D_Gate% 1
    netsh int ip show config
    pause
    goto end

    :PB
    @echo off
    echo "Please enter Static IP Address Information"
    echo "Static IP Address:"
    set /p IP_Addr=10.1.1.5

    echo "Default Gateway:"
    set /p D_Gate=10.1.1.254

    echo "Subnet Mask:"
    set /p Sub_Mask=255.255.255.0

    echo "Setting Static IP Information"
    netsh interface ip set address "Local Area Connection" static %IP_Addr% %Sub_Mask% %D_Gate% 1
    netsh int ip show config
    pause
    goto end
    :end



    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Batch giving invalid address parameter
    « Reply #1 on: July 13, 2017, 05:03:29 PM »
    I don't understand what hyou are doing...
    But if it were me.... I would remove
    @echo off
    Waut untill you have the thing working, then turn off echo. The echo is an aid to let you visualize what the commands are doing. Lrt it  teach you.

    dark0Prince

      Topic Starter


      Newbie

      • Experience: Beginner
      • OS: Windows 10
      Re: Batch giving invalid address parameter
      « Reply #2 on: July 18, 2017, 07:30:56 AM »
      I'm change the IP address with 3 different options

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: Batch giving invalid address parameter
      « Reply #3 on: July 18, 2017, 01:10:57 PM »
      Code: [Select]
      set /p IP_Addr=10.1.4.53

      What do you expect this command to do?
      I was trying to dereference Null Pointers before it was cool.

      Geek-9pm


        Mastermind
      • Geek After Dark
      • Thanked: 1026
        • Gekk9pm bnlog
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: Batch giving invalid address parameter
      « Reply #4 on: July 18, 2017, 10:23:45 PM »
      dark0Prince,
      What you may be seeking is a windows script to change the local static IP address of devices on your local  network.
      I am going to guess that you want to have a party with some friends who bring their own laptops and you join together on the local network. I help identify everybody, you want some way to quickly assign static IP address. before the game starts.
      If so, you should consider using a mix of batch and script commands.
      Or, you might get by just using the "netsh" commands.
      https://www.computerhope.com/netsh.htm
      Quote
      About netsh
      MS-DOS command that enables users to change network settings such as changing their network device from a dynamic address to a static address or changing the IP address.
      Would  that help any?  :)

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: Batch giving invalid address parameter
      « Reply #5 on: July 18, 2017, 11:53:19 PM »
      My question, mind, is that the command

      Code: [Select]
      set /p IP_Addr=10.1.4.53

      Doesn't make much sense.

      Code: [Select]
      set /p Variable=Prompt

      The prompt being simply an IP Address in each case leads me to believe the OP thinks it is assigning the value directly. Remove /p if you don't actually want to prompt for a value.
      I was trying to dereference Null Pointers before it was cool.