Jump to content

VBS to AUTOIT conversion help


Remo1075
 Share

Recommended Posts

Hi folks,

can anyone help me convert this vbs script, I don't know any VBS at all. But it looks like a very simple VBS script for someone to convert.

Const NETWORK_CONNECTIONS = &H31&

Set objShell = CreateObject("Shell.Application")

Set objFolder = objShell.Namespace(NETWORK_CONNECTIONS)

Set colItems = objFolder.Items

For Each objItem in colItems

If objItem.Name = "Wireless Network Connection 1" Then

objItem.Name = "Wireless Network Connection"

End If

If objItem.Name = "Wireless Network Connection 2 " Then

objItem.Name = "Wireless Network Connection"

End If

If objItem.Name = "Wireless Network Connection 3 " Then

objItem.Name = "Wireless Network Connection"

End If

If objItem.Name = "Wireless Network Connection 4 " Then

objItem.Name = "Wireless Network Connection"

End If

If objItem.Name = "Wireless Network Connection 5 " Then

objItem.Name = "Wireless Network Connection"

End If

Next

Thanks before hand

Link to comment
Share on other sites

Hi folks,

can anyone help me convert this vbs script, I don't know any VBS at all. But it looks like a very simple VBS script for someone to convert.

Const NETWORK_CONNECTIONS = &H31&

Set objShell = CreateObject("Shell.Application")

Set objFolder = objShell.Namespace(NETWORK_CONNECTIONS)

Set colItems = objFolder.Items

For Each objItem in colItems

If objItem.Name = "Wireless Network Connection 1" Then

objItem.Name = "Wireless Network Connection"

End If

If objItem.Name = "Wireless Network Connection 2 " Then

objItem.Name = "Wireless Network Connection"

End If

If objItem.Name = "Wireless Network Connection 3 " Then

objItem.Name = "Wireless Network Connection"

End If

If objItem.Name = "Wireless Network Connection 4 " Then

objItem.Name = "Wireless Network Connection"

End If

If objItem.Name = "Wireless Network Connection 5 " Then

objItem.Name = "Wireless Network Connection"

End If

Next

Thanks before hand

Const $NETWORK_CONNECTIONS = &H31&

$objShell = ObjCreate("Shell.Application")
$objFolder = objShell.Namespace(NETWORK_CONNECTIONS)

$colItems = $objFolder.Items
For $objItem in $colItems
   If $objItem.Name = "Wireless Network Connection 1" Then
      $objItem.Name = "Wireless Network Connection"
   EndIf
   If $objItem.Name = "Wireless Network Connection 2 " Then
     $objItem.Name = "Wireless Network Connection"
   EndIf
   If $objItem.Name = "Wireless Network Connection 3 " Then
      $objItem.Name = "Wireless Network Connection"
   EndIf
   If $objItem.Name = "Wireless Network Connection 4 " Then
      $objItem.Name = "Wireless Network Connection"
   EndIf
   If $objItem.Name = "Wireless Network Connection 5 " Then
      $objItem.Name = "Wireless Network Connection"
   EndIf
Next

I think thats'IT but i'm not sure !!! :D

Edited by BoogY
Link to comment
Share on other sites

Hi folks,

can anyone help me convert this vbs script, I don't know any VBS at all. But it looks like a very simple VBS script for someone to convert.

Const NETWORK_CONNECTIONS = &H31&

Set objShell = CreateObject("Shell.Application")

Set objFolder = objShell.Namespace(NETWORK_CONNECTIONS)

Set colItems = objFolder.Items

For Each objItem in colItems

If objItem.Name = "Wireless Network Connection 1" Then

objItem.Name = "Wireless Network Connection"

End If

If objItem.Name = "Wireless Network Connection 2 " Then

objItem.Name = "Wireless Network Connection"

End If

If objItem.Name = "Wireless Network Connection 3 " Then

objItem.Name = "Wireless Network Connection"

End If

If objItem.Name = "Wireless Network Connection 4 " Then

objItem.Name = "Wireless Network Connection"

End If

If objItem.Name = "Wireless Network Connection 5 " Then

objItem.Name = "Wireless Network Connection"

End If

Next

Thanks before hand

Hi,

only tested for real installed adapters. You have to test it for wireless adapters. You should control the registry in the mentioned reg hive beforehand and make some changes to code if necessary.

Dim $networkadapters [10] ; 10 Networkadapters
$newname = "Wireless Network Connection"
;Reading Reg Values (GUID) from installed Adapters
For $i= 1 to 10
    $var = RegEnumKey("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}", $i)
    If @error <> 0 then ExitLoop
    $networkadapters [$i] = $var
Next
;Loop over GUID and looking for name
For $i = 1 To UBound ($networkadapters) - 1
    If $networkadapters [$i] = "" Then ExitLoop
    $name = RegRead ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\" & _
    $networkadapters [$i] & "\Connection", "Name")
    Switch $name
        Case "Wireless Network Connection 1", "Wireless Network Connection 2", "Wireless Network Connection 3", "Wireless Network Connection 4", _
            "Wireless Network Connection 5"
            RegWrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\" & _
            $networkadapters [$i] & "\Connection", "Name", "REG_SZ", $newname)
    EndSwitch
Next

;-))

Stefan

Link to comment
Share on other sites

Hi,

only tested for real installed adapters. You have to test it for wireless adapters. You should control the registry in the mentioned reg hive beforehand and make some changes to code if necessary.

Dim $networkadapters [10] ; 10 Networkadapters
$newname = "Wireless Network Connection"
;Reading Reg Values (GUID) from installed Adapters
For $i= 1 to 10
    $var = RegEnumKey("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}", $i)
    If @error <> 0 then ExitLoop
    $networkadapters [$i] = $var
Next
;Loop over GUID and looking for name
For $i = 1 To UBound ($networkadapters) - 1
    If $networkadapters [$i] = "" Then ExitLoop
    $name = RegRead ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\" & _
    $networkadapters [$i] & "\Connection", "Name")
    Switch $name
        Case "Wireless Network Connection 1", "Wireless Network Connection 2", "Wireless Network Connection 3", "Wireless Network Connection 4", _
            "Wireless Network Connection 5"
            RegWrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\" & _
            $networkadapters [$i] & "\Connection", "Name", "REG_SZ", $newname)
    EndSwitch
Next

;-))

Stefan

Hey thanks to you both for the work, if I can get this to work it will finnish of my script nicely. I get the below error when running this script.

==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$networkadapters [$i] = $var

^ ERROR

>Exit code: 1 Time: 0.273

I'm not good enough with autoit yet to work that error out.

Link to comment
Share on other sites

Hey thanks to you both for the work, if I can get this to work it will finnish of my script nicely. I get the below error when running this script.

==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$networkadapters [$i] = $var

^ ERROR

>Exit code: 1 Time: 0.273

I'm not good enough with autoit yet to work that error out.

Hi,

you may try now the working WMI solution or change

For $i= 1 to 10

to

For $i= 1 to 9 (sry, my coding fault)

Here is WMI:

Const $NETWORK_CONNECTIONS = 0x31

$objShell = ObjCreate("Shell.Application")
$objFolder = $objShell.Namespace($NETWORK_CONNECTIONS)

$colItems = $objFolder.Items
For $objItem in $colItems
    Switch $objItem.Name
        Case "Wireless Network Connection 1", "Wireless Network Connection 2", "Wireless Network Connection 3", "Wireless Network Connection 4", _
            "Wireless Network Connection 5"
            $objItem.Name = "Wireless Network Connection"       
    EndSwitch
Next

;-))

Stefan

P.S: Both solutions are not tested with wireless adapters

Edited by 99ojo
Link to comment
Share on other sites

Hi,

you may try now the working WMI solution or change

For $i= 1 to 10

to

For $i= 1 to 9 (sry, my coding fault)

Here is WMI:

Const $NETWORK_CONNECTIONS = 0x31

$objShell = ObjCreate("Shell.Application")
$objFolder = $objShell.Namespace($NETWORK_CONNECTIONS)

$colItems = $objFolder.Items
For $objItem in $colItems
    Switch $objItem.Name
        Case "Wireless Network Connection 1", "Wireless Network Connection 2", "Wireless Network Connection 3", "Wireless Network Connection 4", _
            "Wireless Network Connection 5"
            $objItem.Name = "Wireless Network Connection"       
    EndSwitch
Next

;-))

Stefan

P.S: Both solutions are not tested with wireless adapters

Thank you thank you thank you,

WMI script works great, this was my preferred way of doing it. I can finally finnish my main script and put it to rest. This has been nagging me for a while now.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...