Click to See Complete Forum and Search --> : is there a network object to change IP?
DMcManus
Jul 12th, 2000, 02:11 PM
I have a user who goes between two different places and we would like to set up his laptop so that he could easily configure his machine on either network.
I thought perhaps we could write some VBScript and use the Windows Scripting Host...but I don't know if there is any objects that I can use to get to his IP address and his subnet mask and gateway and anything else. So, is there anyway to get to this properties through WSH?
Thanks
--Dan
dvst8
Jul 12th, 2000, 02:26 PM
this doesnt really answer your question, but i know you can get a user's IP in ASP with
Request.ServerVariables("REMOTE_ADDR")
dvst8
DMcManus
Jul 12th, 2000, 02:34 PM
No, you're right, it doesn't at all.
I'm not talking about a client IP.
And I'm not talking about ASP or web use at all, so there is no request object.
I'm talking about a script that would run in windows (thanks to the Windows Scripting Host) and be able to change the assigned IP address of the OS.
but thanks for trying I guess.
(:
dvst8
Jul 12th, 2000, 02:39 PM
sorry man
james.howell
Jul 15th, 2007, 05:39 PM
I realise that this is an old thread, but while looking for some help with using Windows Scripting Host in VB .NET 2005 I came accross it, and having run into this problem myself I thought I would post my solution.
I have been using this method successfully moving my XP laptop between work and home for the last year or so with no problems.
All you need to do is make the relevant settings in the batch file, and then save it with a meaningful name, and have the user double click the correct one dependent on location.
If the user has different user accounts for different locations then just put it in the startup folder.
This batch file will set the IP address of the computer to a static address:
@echo off
echo Automatic IP Address settings v1.0
echo written February 2006 by James Howell
echo Configuring IP Address:
rem set the fixed IP address
rem settings are in the format: connection name | type | ip | subnet | gateway
netsh interface ip set address "Local Area Connection" static 172.20.25.7 255.255.0.0 172.20.0.2 1
echo.
echo Configuring DNS Address:
rem This line appears twice to allow for the primary and secondary DNS server settings
netsh interface ip set dns "Local Area Connection" static addr=172.20.10.2
netsh interface ip add dns "Local Area Connection" 172.20.10.1 index=1
echo.
echo The following details have been set:
rem echo the settings back to the user
netsh interface ip show config name="Local Area Connection"
echo.
rem wait for the user to exit the program
echo Press any key to exit
pause > Nul
exit
This batch file will set the IP address of the computer to a dynamic address:
@echo off
echo Automatic IP Address settings v1.0
echo written February 2006 by James Howell
echo Configuring IP Address:
rem set the dynamic IP address
netsh interface ip set address name="Local Area Connection" source=dhcp
echo.
echo Configuring DNS Address:
rem set the dynamic dns address
netsh interface ip set dns name="Local Area Connection" source=dhcp
echo.
echo The following details have been set:
rem echo the settings back to the user
netsh interface ip show config name="Local Area Connection"
echo.
rem wait for the user to exit the program
echo Press any key to exit
pause > Nul
exit
Anyway, that's my solution. If anyone finds it useful, it would be nice if you could let me know.
James
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.