Set manual ip address from user input Solved

  1.    31 Jan 2017 #1

    Set manual ip address from user input

    Hi all,

    Can someone point out where I've gone wrong with this batch file.

    I know it has to be run as an administrator to function correctly.

    netsh interface ip set address name="Ethernet" source=dhcp
    set /p userInputIP= Enter the 4 DIGIT Number [inc decimal point] (example 90.21) ?
    netsh interface ip set address name= ”Ethernet” static 1.%userinputip%.1 1.%userinputip%.254
    netsh interface ip set dns “Local Area Connection” static 1.200.300.1
    reg add HKLM\System\CurrentControlSet\Services\Tcpip\Parameters /v "SearchList" /d "" /f

    The basis here is that a 4 digit number is entered by the user eg: 90.21 which goes into the variable 'userinputip', then this is transferred into the ip address so it becomes

    The funny thing is that if I set the static ip in the program it will work.

    If I pause the program after it attempt to input the new ip adress, it does look as if it has worked, yet when I check it with ipconfig it shows that it hasn't, returning the dhcp address.

    Perhaps what I want isn't possible, if that's the case then I have a few ideas:

    The pc name will have numbers in it, like 9021 which can be resolved into a text file from dos using the command echo %computername% > c:\name.txt

    This would return pc9021 providing the pc is named pc9021 into a text file, but how would I import the 9021 and make it ??

    Hope this makes sense, and thanks in advance for any help.
      My ComputerSystem Spec

  2.    31 Jan 2017 #2

    What is the point of this how will user know what to enter for subnet,IP etc?
      My ComputerSystem Spec

  3.    31 Jan 2017 #3

    Samuria said: View Post
    What is the point of this how will user know what to enter for subnet,IP etc?
    Subnet is hard coded in the program :

    Gateway and dns are also hard coded in.

    All the user needs to do is enter a 4 digit number with a decimal point between the 2nd and 3rd numbers, the rest is taken care of by the program based on the numbers they enter
      My ComputerSystem Spec

  4. Caledon Ken's Avatar
    Posts : 11,636
    Windows 10 Pro x64 Build 1803
       01 Feb 2017 #4

    Have you searched parsing a variable in a batch command, thinking you may be able to parse computer name.
      My ComputerSystem Spec


Related Threads
Hi I noticed that some services of Windows 10 Preview although I set them on Manual, they are automatically set to "Manual (trigger start". Why? What is the difference between these two startup modes? Lastly, with these services, how do I set...
Can you manually move win app folders from another location to user/appdata? ie I have a very large app 40gb that always has issues downloading. I managed to install it awhile ago and copied it to a backup drive. After windows reinstallation I...
Hello everyone, User is experiencing problem with login screen - input language changed to Russian after some updates and restart, and there is no way to change it back. No language button, shortcuts does not work, and icing on the cake - admin...
Download the Official Microsoft Windows 10 Mobile User Manual Redmond offers info to get around the new operating System Read more:...
(a) Where do we download Windows 10 manuals from, please? (b) Meanwhile the problem that drives me most potty - I use "restored down folders" for many purposes, eg copying files between: but now I can't move them and they sit on top of each...
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 19:35.
Find Us