I am trying to write a script that checks for a specific value in the registry and then deletes that value. In my case, the value is only a subset of the comma separated text within the key value.
I am trying to treat the string "(example: "vmhgfs,RDPNP,LanmanWorkstation,webclient" as an array bySPLITing into multiple elements and then setting the unwanted array element toEMPTY. I then want to write the value back as a string but without the element I'm removing (Example:"RDPNP,LanmanWorkstation,webclient".
The script properly reads the value from the registry and the SPLIT function works to separate the elements. When I try to JOIN the elements into a new string, I still get a ',' (comma) delimiter for the element I've removed (example:,RDPNP,LanmanWorkstation,webclient).
How do I do this so that the comma is not created? Is there a better way to do this? I know I could parse the text string and remove the comma but that seems like sloppy coding and the element I'm removing is not always in the same place.
' ' Purpose: Check for VMWare Tools Shared Folders Provider Dim strRegArray, strRegValue Dim I Set WshShell = CreateObject( "WScript.Shell" ) 'Bind to the Registry provider strRegValue = WshShell.RegRead( "HKLM\System\CurrentControlSet\Control\NetworkProvider\Order\ProviderOrder" ) strRegArray = Split(strRegValue,",") 'Copy Registry values into an Array For I = 0 To UBound (strRegArray) If strRegArray(I) = "vmhgfs" Then strRegArray(I) = Empty End If strNewArray = Join(strRegArray, ",") Next WScript.Echo strNewArray