tron Posted September 11, 2004 Share Posted September 11, 2004 Hi guys,i try to setup my Runonce.cmd like FTP Installation Thread. But i have to setup my IP-Adress first. I dont have a DHCP Server so i have to set this static. But my friends also use this Installation. So i cant setup my network 192.168.122.x. I have to ask for it in ipadress.bat:Here is the code:@echo off echo Ipadresse festlegenecho per DHCP Server:set /p ip1=(j/n): if /i %ip1%==j netsh interface ip set address "LAN-Verbindung" dhcppauseecho Static settings:set /p ip2=(j/n): if /i %ip2%==j netsh interface ip set address "LAN-Verbindung" staticexitDHCP works fine, but how could i set Variables for static settings? Store them in txt file?!Hope you could help me.Thx tron Link to comment Share on other sites More sharing options...
maxXPsoft Posted September 11, 2004 Share Posted September 11, 2004 I think i recognize that ip, Starband ? I'm not sure what you're trying to do but I import a reg file and mine is setup. Check "ProxyServer" under this key[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]I save and import the whole key. But mine is a workstation on a LAN so not sure that would help you if you're directly connected. Link to comment Share on other sites More sharing options...
CoffeeFiend Posted September 11, 2004 Share Posted September 11, 2004 There's many ways around this problem1) straight import registry file (probably will fail/have issues in many cases depending on hardware and what not)2) vbscript, using the Win32_NetworkAdapterConfiguration WMI class (I just love WMI, but do we always have to resort to that for every single small thing?)3) netsh command line utility, for static IP (which is the one I'd use personally):netsh interface ip set address "Local Area Connection" static ipaddr subnetmask gateway metricie:netsh interface ip set address "Local Area Connection" static 192.168.0.10 255.255.255.0 192.168.0.1 1of course you have to change numbers to match whatever your case might be. There probably are more ways to this as well. Link to comment Share on other sites More sharing options...
tron Posted September 11, 2004 Author Share Posted September 11, 2004 Thanks for the answers.crahak netsh is the thing i want. But IP Adress Netmask and Gateway i couldnt set static. In the script there have to be a prompt, where you could type in IP, Netmask and Gateway in. Like in linux...Then maybe stored in a .txt file and inserted in netsh...I dont know much about vbscript so i dont know what i have to do with the WMI...Greetz tron Link to comment Share on other sites More sharing options...
edg21 Posted September 11, 2004 Share Posted September 11, 2004 Configure your PC for static IP then run this to dump your settings to a txt file.netsh -c interface dump > c:\location.txtCopy location.txt to your unattended cd & run this in your batch to set it static.netsh -f c:\location.txtOr you could use something like this:set STATIC_IP=192.168.1.105set SUBNET=255.255.255.0set GATEWAY=192.168.1.1netsh int ip add name="Local Area Connection" static %STATIC_IP% %SUBNET% %GATEWAY% 1Info from: http://www.petri.co.il/configure_tcp_ip_from_cmd.htmhope that helps.... Link to comment Share on other sites More sharing options...
tron Posted September 11, 2004 Author Share Posted September 11, 2004 Hello edg21,set STATIC_IP=192.168.1.105 <-- User have to insert this information on command promptset SUBNET=255.255.255.0 <-- User have to insert this information on command promptset GATEWAY=192.168.1.1 <-- User have to insert this information on command promptnetsh int ip add name="Local Area Connection" static %STATIC_IP% %SUBNET% %GATEWAY% 1^^ This is very good, but i want to call this file on Runonce.cmd to set the Networksettings before running your ftp.cmd. The thing is that my friends also want to use this CD. His network is different, but to call your ftp.cmd he has to input his IP, Mask and Gateway. So i couldnt set these Options static. My idea was to have a prompt like in linux where he could insert his Networksettings. He also has no DHCP. We need this to have in the next step an internet connection to start your ftp.cmd file.Hope you understand what i mean.Thx & Greetz tron Link to comment Share on other sites More sharing options...
joebells Posted September 12, 2004 Share Posted September 12, 2004 what if you just leave the networking section out of your winnt.sif that way it will ask you to set your networking options like it normally would. Link to comment Share on other sites More sharing options...
tron Posted September 12, 2004 Author Share Posted September 12, 2004 joebells this is an opinion...LOL often it is just too easy.thx i try that Link to comment Share on other sites More sharing options...
joebells Posted September 12, 2004 Share Posted September 12, 2004 you're welcome Link to comment Share on other sites More sharing options...
edg21 Posted September 12, 2004 Share Posted September 12, 2004 ^^ This is very good, but i want to call this file on Runonce.cmd to set the Networksettings before running your ftp.cmd. The thing is that my friends also want to use this CD. His network is different, but to call your ftp.cmd he has to input his IP, Mask and Gateway. So i couldnt set these Options static. My idea was to have a prompt like in linux where he could insert his Networksettings. He also has no DHCP. We need this to have in the next step an internet connection to start your ftp.cmd file.Somethin kinda like this?:NW_CHOOSEECHO.ECHO 1. Set static IPECHO 2. Use DHCPSET /P NW_CONF=[Do you want to specify a static IP or use DHCP? (Select 1 or 2)]IF /I "%NW_CONF%" == "1" GOTO NW_SET_DHCPIF /I "%NW_CONF%" == "2" GOTO NW_INPUT:NW_INPUTSET /P STATIC_IP=[IP:]SET /P SUBNET=[Subnet Mask:]SET /P GATEWAY=[Default Gateway:]ECHO.ECHO You specified:ECHO IP Address: %WEB_ADDY%ECHO Subnet Mask: %WEB_ADDY%ECHO Default Gateway: %WEB_ADDY%:NW_CONFIRMECHO.SET /P NW_CONF=[Is this correct? Y/N:]IF /I "%NW_CONF%" == "Y" GOTO NW_SETIF /I "%NW_CONF%" == "N" GOTO NW_INPUTGOTO NW_CONFIRM:NW_SET_STATICnetsh int ip add name="Local Area Connection" static %STATIC_IP% %SUBNET% %GATEWAY% 1GOTO END:NW_SET_DHCPnetsh int ip set add "Local Area Connection" dhcpGOTO END:END Link to comment Share on other sites More sharing options...
tron Posted September 12, 2004 Author Share Posted September 12, 2004 edg21 you are the man.... really really good. Thats what ive searching for...Ive modified the script a bit and it is still in Progress.@echo off:NW_CHOOSEECHO.ECHO 1. per DHCPECHO 2. Statische IP-AdresseSET /P NW_CONF=[Do you want to use DHCP or specify a static IP? (Select 1 or 2)]IF /I "%NW_CONF%" == "1" GOTO NW_SET_DHCPIF /I "%NW_CONF%" == "2" GOTO NW_INPUT:NW_INPUTSET /P STATIC_IP=[IP:]SET /P SUBNET=[Subnet Mask:]SET /P GATEWAY=[Default Gateway:]ECHO.ECHO You specified:ECHO IP Address: %STATIC_IP%ECHO Subnet Mask: %SUBNET%ECHO Default Gateway: %GATEWAY%:NW_CONFIRMECHO.SET /P NW_CONF=[Is this correct? Y/N:]IF /I "%NW_CONF%" == "Y" GOTO NW_SETIF /I "%NW_CONF%" == "N" GOTO NW_INPUTGOTO NW_CONFIRM:NW_SET_STATICnetsh int ip add name="Local Area Connection" static %STATIC_IP% %SUBNET% %GATEWAY% 1GOTO END:NW_SET_DHCPnetsh int ip set add "Local Area Connection" dhcpGOTO END:ENDYoure so great greetz tron Link to comment Share on other sites More sharing options...
Anderz Posted September 17, 2004 Share Posted September 17, 2004 edg21: Good job! I suddenly needed this myself! GREAT! Link to comment Share on other sites More sharing options...
Weed Posted September 17, 2004 Share Posted September 17, 2004 and when having more then 1 nw adapters? i have 3 adapters Link to comment Share on other sites More sharing options...
edg21 Posted September 17, 2004 Share Posted September 17, 2004 and when having more then 1 nw adapters? i have 3 adaptershmmmm... something like this maybe? Haven't tested it so let me know if it works @echo off:NW_CHOOSEECHO.ECHO 1. per DHCPECHO 2. Statische IP-AdresseSET /P NW_CONF=[Do you want to use DHCP or specify a static IPs? (Select 1 or 2)]IF /I "%NW_CONF%" == "1" GOTO NW_SET_DHCPIF /I "%NW_CONF%" == "2" GOTO NW_INPUT:NW_INPUTECHO Setup 1st Adapter:SET /P STATIC_IP1=[IP:]SET /P SUBNET1=[Subnet Mask:]SET /P GATEWAY1=[Default Gateway:]ECHO.ECHO Setup 2nd Adapter:SET /P STATIC_IP2=[IP:]SET /P SUBNET2=[Subnet Mask:]SET /P GATEWAY2=[Default Gateway:]ECHO.ECHO Setup 3rd Adapter:SET /P STATIC_IP3=[IP:]SET /P SUBNET3=[Subnet Mask:]SET /P GATEWAY3=[Default Gateway:]ECHO You specified:ECHO Adapter 1 - IP: %STATIC_IP1% MASK: %SUBNET1% GW:%GATEWAY1%ECHO Adapter 2 - IP: %STATIC_IP2% MASK: %SUBNET2% GW:%GATEWAY2%ECHO Adapter 3 - IP: %STATIC_IP3% MASK: %SUBNET3% GW:%GATEWAY3%:NW_CONFIRMECHO.SET /P NW_CONF=[Is this correct? Y/N:]IF /I "%NW_CONF%" == "Y" GOTO NW_SET_STATICIF /I "%NW_CONF%" == "N" GOTO NW_INPUTGOTO NW_CONFIRM:NW_SET_STATICnetsh int ip add name="Local Area Connection" static %STATIC_IP1% %SUBNET1% %GATEWAY1% 1netsh int ip add name="Local Area Connection 2" static %STATIC_IP2% %SUBNET2% %GATEWAY2% 1netsh int ip add name="Local Area Connection 3" static %STATIC_IP3% %SUBNET3% %GATEWAY3% 1GOTO END:NW_SET_DHCPnetsh int ip set add "Local Area Connection" dhcpnetsh int ip set add "Local Area Connection 2" dhcpnetsh int ip set add "Local Area Connection 3" dhcpGOTO END:END Link to comment Share on other sites More sharing options...
Weed Posted September 17, 2004 Share Posted September 17, 2004 it looks nice =)cant test it now but how do i know which adapter is 2nd adapter,... ? when doing "ipconfig /?" in command line there is a switch "ipconfig /renew EL*" so i can use the Line for example ipconfig /renew 3COM*isnt it possible with netsh too? hm it looks like not Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now