/build/static/layout/Breadcrumb_cap_w.png

Need somewhere to post this script

ON ERROR RESUME NEXT

Dim strFlag
Dim regmode

strValueToRemove = "Mvfs"

Set objShell = CreateObject("WScript.Shell")

If Wscript.Arguments.Count > 0 Then
strFlag = Wscript.arguments.Item(0)
End If

If IsEmpty(strFlag) Then Wscript.quit 'No arguments have been received

'objShell.Popup strFlag,0,"args are","48"

If strFlag = "/u" Then regmode = "remove"
If strFlag = "/i" Then regmode = "add"



'Read the registry keys into variables
strCurrentValue_HwOrder = objShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\HwOrder\ProviderOrder")
strCurrentValue_Order = objShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order\ProviderOrder")

'Split the value to an array and go through each one looking for the "value to remove". If found, exclude it from the new value.
arrHwOrder = Split(strCurrentValue_HwOrder, ",", -1, 1)
For x = 0 to UBound(arrHwOrder)
If arrHwOrder(x) <> strValueToRemove Then strNewValue_HwOrder = strNewValue_HwOrder & "," & arrHwOrder(x)
Next
arrOrder = Split(strCurrentValue_Order, ",", -1, 1)
For x = 0 to UBound(arrOrder)
If arrOrder(x) <> strValueToRemove Then strNewValue_Order = strNewValue_Order & "," & arrOrder(x)
Next


If regmode = "add" Then
strNewValue_HwOrder = strValueToRemove & strNewValue_HwOrder
strNewValue_Order = strValueToRemove & strNewValue_Order
'objShell.Popup strNewValue_HwOrder,0,"Add Hardware order","48"
'objShell.Popup strNewValue_Order,0,"Add order","48"
'Write the new registry values. This way if removing.
objShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\HwOrder\ProviderOrder", strNewValue_HwOrder, "REG_SZ"
objShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order\ProviderOrder", strNewValue_Order, "REG_SZ"
End If


If regmode = "remove" Then
'Write the new registry values. This way if removing.
'objShell.Popup Mid(strNewValue_HwOrder, 2),0,"Remove Hardware order","48"
'objShell.Popup Mid(strNewValue_Order, 2),0,"Remove order","48"
objShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\HwOrder\ProviderOrder", Mid(strNewValue_HwOrder, 2), "REG_SZ"
objShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order\ProviderOrder", Mid(strNewValue_Order, 2), "REG_SZ"
End If

0 Comments   [ + ] Show comments

Answers (1)

Posted by: anonymous_9363 12 years ago
Red Belt
0
Hmmm...

- No 'Option Explicit'
- Zero error-handling (never mind, everything always works 100%, right?)
- Code repetition (registry key strings)
- Superfluous code, e.g.:If strFlag = "/u" Then regmode = "remove"
If strFlag = "/i" Then regmode = "add"
<snip>
If regmode = "remove" Then
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ