Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 31st, 2004, 02:22 PM
mparker1113 mparker1113 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 254 mparker1113 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 29 m 48 sec
Reputation Power: 5
Need to allow user to toggle Network IP Addresses

Hi:

I have a user who needs to be able to use one static ip address on a network for her laptop, and another static ip address for a different network.

How would you guys approach writing a script which could be used to toggle between the two ip addresses?

I found an article for a VBS script that claimed to be able to do this. Does the code look good to you?

Code:
Set oLocator = New SWbemLocator
Set oServices = oLocator.ConnectServer(, "root\cimv2")
Set oObject = oServices.Get("Win32_NetworkAdapterConfiguration.Index=0")
Dim asIPAddress
Dim asSubnetMask
asIPAddress = Array("xxx.xxx.xxx.xxx")
asSubnetMask = Array("xxx.xxx.xxx.xxx")
Set oMethod = oObject.Methods_("EnableStatic")
Set inParam = oMethod.InParameters.SpawnInstance_()
inParam.IPAddress = asIPAddress
inParam.SubnetMask = asSubnetMask
Set outParam = oObject.ExecMethod_("EnableStatic", inParam)
If outParam.returnValue = 0 Then
  MsgBox "Method Succeeded."
Else
  MsgBox "Method Failed. " & CStr(outParam.returnValue)


Thank you very much for any pointers.

Mike

Reply With Quote
  #2  
Old September 13th, 2004, 02:42 PM
mparker1113 mparker1113 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 254 mparker1113 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 29 m 48 sec
Reputation Power: 5
Hi, so when I run this:

Code:
Set oLocator = CreateObject("WbemScripting.SWbemLocator")   'New SWbemLocator
Set oServices = oLocator.ConnectServer(,"root\cim2")                             '(,"root\default")
Set oObject = oServices.Get("Win32_NetworkAdapterConfiguration.Index=0")
Dim asIPAddress
Dim asSubnetMask
asIPAddress = Array("xxx.xxx.138.47")
asSubnetMask = Array("255.255.255.0")
Set oMethod = oObject.Methods_("EnableStatic")
Set inParam = oMethod.InParameters.SpawnInstance_()
inParam.IPAddress = asIPAddress
inParam.SubnetMask = asSubnetMask
Set outParam = oObject.ExecMethod_("EnableStatic", inParam)
If outParam.returnValue = 0 Then
  MsgBox "Method Succeeded."
Else
  MsgBox "Method Failed. " & CStr(outParam.returnValue)

End If

The error message i get is:
Script:\ChangeIPAddress.vbs
Line: 2
Char: 1
Error: Invalid Namespace

Code: 8004100E
Source: SWbemLocator

Anyone able to work on this with me?

Much thanks.

Mike

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > Need to allow user to toggle Network IP Addresses


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway