1.    31 Jan 2017 #1
    Join Date : Apr 2016
    Posts : 8
    Windows 10

    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 255.255.255.0 1.%userinputip%.254
    netsh interface ip set dns “Local Area Connection” static 1.100.200.1 1.200.300.1
    reg add HKLM\System\CurrentControlSet\Services\Tcpip\Parameters /v "SearchList" /d "servername.net" /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 1.90.21.1

    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 1.90.21.1 ??

    Hope this makes sense, and thanks in advance for any help.
      My ComputerSystem Spec
  2.    31 Jan 2017 #2
    Join Date : Jul 2016
    Crewe Cheshire
    Posts : 1,466
    windows 10

    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
    Join Date : Apr 2016
    Posts : 8
    Windows 10
    Thread Starter

    Quote Originally Posted by Samuria 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 : 255.255.255.0

    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.    01 Feb 2017 #4
    Join Date : Oct 2016
    Caledon, Ontario, Canada
    Posts : 4,109
    Windows 10 Pro Build 1703

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

 


Similar Threads
Thread Forum
Difference between the Manual and Manual (trigger start) services
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...
General Support
Manual move of win apps in user/appdata
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...
Software and Apps
Win 10 changes user input language at login screen, unable to fix
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...
General Support
Mobile Download the Official Microsoft Windows 10 Mobile User Manual
Download the Official Microsoft Windows 10 Mobile User Manual Redmond offers info to get around the new operating System Read more:...
Windows 10 News
Windows 10 (a) manual/user guide: where? (b) how to move folders?
(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...
General Support
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 17:11.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums