Answered by:

How can i rename the Local Area Connection??

Question

If in my system thr is more than one Local Area Connection like Local Area Connection2, Local Area Connection3, etc like that i need to change only any one that name. How it can be done using vbscript???For single connection i hav done it. Const NETWORK_CONNECTIONS = &H31&

Answers

Set colItems = objFolder.Items For Each objItem in colItems If Instr(objItem.Name, "Local Area Connection") <> 0 Then objItem.Name = Replace(objItem.Name, "Local Area Connection", "Office Connection") End If Next

It replaces the "Local Area Connection" string in the name with "Office Connection".

If you want different names, put them in an array and use the number at the end to index the array, something like this ...

aNames = Array("Name_1, "Name_2", "Name_3") Set colItems = objFolder.Items For Each objItem in colItems If Instr(objItem.Name, "Local Area Connection") <> 0 Then idx = Replace(objItem.Name, "Local Area Connection", "") - 1 if not (idx > UBound(aNames)) and idx > -1 then objItem.Name = aNames(idx) End If Next

All replies

Set colItems = objFolder.Items For Each objItem in colItems If Instr(objItem.Name, "Local Area Connection") <> 0 Then objItem.Name = Replace(objItem.Name, "Local Area Connection", "Office Connection") End If Next

It replaces the "Local Area Connection" string in the name with "Office Connection".

If you want different names, put them in an array and use the number at the end to index the array, something like this ...

aNames = Array("Name_1, "Name_2", "Name_3") Set colItems = objFolder.Items For Each objItem in colItems If Instr(objItem.Name, "Local Area Connection") <> 0 Then idx = Replace(objItem.Name, "Local Area Connection", "") - 1 if not (idx > UBound(aNames)) and idx > -1 then objItem.Name = aNames(idx) End If Next

Hi Tom thanx for your reply. But wat i need is first it should ask to type the Local Area Connection Name for eg: Local Area Connection3 then it should ask to type the new name like eg:connection . I need it in dis may. Is thr any script. I dont want to put in array.

Microsoft is conducting an online survey to understand your opinion of the Technet Web site. If you choose to participate, the online survey will be presented to you when you leave the Technet Web site.