Using scripts to change IP settings

Discussion in 'Hardware' started by kosmicken, Nov 7, 2007.

  1. kosmicken

    kosmicken Private E-2

    I use my laptop on several different networks with different IP schemes, none of which use DHCP. So I have to constantly change my IP settings. I found this site that explains how to use the NETSH command, and then create a .vbs script to automate the process. I created a script and saved it to the desktop, but it's not working. The only difference between my script and their example is the actual numbers used in my addresses. Everything else is the same. Here is the error message I get every time I try to run the script:

    Script: C:\Documents and Setting\...
    Line: 1
    Char: 11
    Error: Expected end of statement
    Code: 800A0401
    Source: Microsoft VBScript compilation error

    I tried Googling that error code, but most of what I found is way over my head. I know nothing of Visual Basic, but it looks like this should be easy. Any idea what the problem is?
     
  2. kosmicken

    kosmicken Private E-2

    I guess know the OS would help. XP Pro. :)
     
  3. foogoo

    foogoo Major "foogoo" Geek

    You can get programs to do that:
    http://www.lyrasoftware.com//content/view/6/8/
    Netchange is a small tool for changing the tcp/ip settings of a
    computer. it is much faster than manual change, and also saves the
    settings automatically. This program is recommened for laptop users who
    go from one place to another, visit customers or changing access
    points/lans often.
    There was one called winips, but their domain is no longer registered.
    WinIPs is a single exe and runs in the task tray for easy access.Contact me I can send it. I googled the name but there were no mirrors. I think I got it from www.portablefreeware.com originally.

    There is also a shareware one I tried out, in the unpaid version you could have 5 different settings, I don't recall the name, I went with winips, it has the most options and is easier to use.
     
  4. kosmicken

    kosmicken Private E-2

    Yeah, but it's so much more fun if you can create a script yourself to take advantage of existing tools. After all, this is Major Geeks, right? :D
     
  5. kosmicken

    kosmicken Private E-2

    I never did find a solution to this. I put it on the back burner for awhile, but now I really wanna figure it out. Following is the text of the script I am trying to execute:

    netsh int ip set address name="Local Area Connection" source=static
    addr=192.168.10.25 mask=255.255.255.0

    I typed this into Notepad and saved the file to my desktop with a .vbs extension. When I double click the file, I get the error mentioned in my first post. Googling the error tells me that there is a problem with character 11 on line 1 of the script. Why? I double and triple checked all my spelling and punctuation. When I run these commands from the command prompt, they work just fine. Why am I having trouble running them from a script?
     
  6. foogoo

    foogoo Major "foogoo" Geek

    Because a vbs is not a bat. If it works from the command prompt you can make a BATch file in notepad, vbs files run with wscript - is that major geek enough?
     
  7. KingSteve

    KingSteve MajorGeek

    i could probably fix it for you. can i see the script? you probably forgot a quote somewhere on line 1 char 11. use notepad ++ its a lot easier to see everything than just on notepad.
     
  8. kosmicken

    kosmicken Private E-2

    The files are saved with .vbs extensions (not .txt). They do run in wscript. Did you read any of the info in the link in my first post? I followed those directions exactly, changing only the numbers appropriate to my networks.

    Steve, the text of the script is in the second paragraph of my previous post. That's it. Nothing fancy. I don't know much about how scripts work, but according to the article I linked to, if you type this in notepad and save it with a .vbs extension, it should work. Am I missing something?
     
  9. KingSteve

    KingSteve MajorGeek

    yeah i dont know. i tried to play with it a little but no luck. sorry. try the programming section if you didnt yet.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds