petrosyg
asked on
Re-Ordering Network Provider order in Windows - Modify a VB Script
I have used this script by Anders Olsson to Chang Network Provider order in Windows.. It works very well.
I would like to modify it to where "LanmanWorkstation" will be first and "NCredMgr" to be last. The once in between does not matter the order.
eg. "LanmanWorkstation, NetwareWorkstation, RDPNP, WebClient, NCredMgr"
Andres Olsson Script: (I am attaching it as well)
'
' ChangeProviderOrder.vbs, by Anders Olsson, Kentor Teknik AB, 2006-10-31
'
' Reads the "Network provider order" from the registry and reorders it putting
' the "Microsoft Windows Networking" provider on top.
'
' Example: Before - "NCredMgr,NetwareWorkstati on,RDPNP,L anmanWorks tation,Web Client"
' would become "LanmanWorkstation,NCredMg r,NetwareW orkstation ,RDPNP,Web Client" after
' running this script.
'
Set WshShell = WScript.CreateObject("WScr ipt.Shell" )
' Read the reg value of the providers
strKey = WshShell.RegRead("HKLM\SYS TEM\Curren tControlSe t\Control\ NetworkPro vider\Orde r\Provider Order")
' Split the strings up using comma (ASCII #44) as the delimiter
arrProvs = Split(strKey, chr(44), -1, 1)
' If LanmanWorkstation is already first, we don't have to do anything
If arrProvs(0) = "LanmanWorkstation" Then
Wscript.Quit(0)
end if
' "LanmanWorkstation" should always start the string
strNewProvs = "LanmanWorkstation"
' Loop through the old provider strings, and add them to the new string. Don't
' write LanmanWorkstation, since it's already written at the start of the string.
For Each strProv In arrProvs
Select Case strProv
Case "LanmanWorkstation"
Case Else strNewProvs = strNewProvs & "," & strProv
End Select
Next
' Write the new string back to the registry
WshShell.RegWrite "HKLM\SYSTEM\CurrentContro lSet\Contr ol\Network Provider\O rder\Provi derOrder", strNewProvs, "REG_SZ"
Network_provider_Order.txt
I would like to modify it to where "LanmanWorkstation" will be first and "NCredMgr" to be last. The once in between does not matter the order.
eg. "LanmanWorkstation, NetwareWorkstation, RDPNP, WebClient, NCredMgr"
Andres Olsson Script: (I am attaching it as well)
'
' ChangeProviderOrder.vbs, by Anders Olsson, Kentor Teknik AB, 2006-10-31
'
' Reads the "Network provider order" from the registry and reorders it putting
' the "Microsoft Windows Networking" provider on top.
'
' Example: Before - "NCredMgr,NetwareWorkstati
' would become "LanmanWorkstation,NCredMg
' running this script.
'
Set WshShell = WScript.CreateObject("WScr
' Read the reg value of the providers
strKey = WshShell.RegRead("HKLM\SYS
' Split the strings up using comma (ASCII #44) as the delimiter
arrProvs = Split(strKey, chr(44), -1, 1)
' If LanmanWorkstation is already first, we don't have to do anything
If arrProvs(0) = "LanmanWorkstation" Then
Wscript.Quit(0)
end if
' "LanmanWorkstation" should always start the string
strNewProvs = "LanmanWorkstation"
' Loop through the old provider strings, and add them to the new string. Don't
' write LanmanWorkstation, since it's already written at the start of the string.
For Each strProv In arrProvs
Select Case strProv
Case "LanmanWorkstation"
Case Else strNewProvs = strNewProvs & "," & strProv
End Select
Next
' Write the new string back to the registry
WshShell.RegWrite "HKLM\SYSTEM\CurrentContro
Network_provider_Order.txt
ASKER
it_saige,
Thank you for the quick response .... I was so close but I see the mistakes that I had on my code .... Let me test it quickly but the logic looks perfect.
Petros
Thank you for the quick response .... I was so close but I see the mistakes that I had on my code .... Let me test it quickly but the logic looks perfect.
Petros
ASKER
it_saige,
I run the script and it errors--- Invalid root in Registry key ....
Just to let you know, Not all devices have the NCredMgr in their list .... could that be causing the issue?
I should have specified first, my initial attempt was to put "LanmanWorkstation" first and if "NCredMgr" exist, to put it last.
Thank you for any input.
error-message-.JPG
I run the script and it errors--- Invalid root in Registry key ....
Just to let you know, Not all devices have the NCredMgr in their list .... could that be causing the issue?
I should have specified first, my initial attempt was to put "LanmanWorkstation" first and if "NCredMgr" exist, to put it last.
Thank you for any input.
error-message-.JPG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, let me give it a try!
ASKER
Great logic ... appreciate it works perfectly sofar
Open in new window
-saige-