Thursday, June 19, 2014

Renaming Local area connection using Vb Scripts

On Error Resume Next
Const NETWORK_CONNECTIONS = &H31&
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter")

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(NETWORK_CONNECTIONS)

Set colItems = objFolder.Items
For Each objItem in colItems
    If objItem.Name = "Local Area Connection" Then
       objItem.Name = "Local Area Connection 2"
    End If
Next

No comments:

Post a Comment