Cant_Code
Ideally it would be something like this
FlHndl = FileOpen("ShareFromReg.txt", READ)
While NotEOF do
X=ReadFile(FlHndl)
Val=Split(x,@TAB)[0]
Data=Split(x,@TAB)[1]
Run("reg add HKLM\System\currentcontrolset\services\lanmanserver\shares /v $Val /t REG_MULTI_SZ /d $Data ")
Endwhile
FileClose(FlHndl)
Print("Check the registry to see if it all works.")
Use the
SetMultiStringValue() method to write REG_MULTI_SZ values to the registry with a VBScript.
Cant_Code
I've tried to script splitting the data at the tabs but am stuck. Here is what I have
Let's take a closer look at what you're doing here, and what actual values that generates:
strLine = objFile.ReadLine
REM strLine = "VBS REG_MULTI_SZ CSCFlags=0\0MaxUses=4294967295\0Path=..."
arrFields = Split(strLine, vbTab)
REM arrFields = Array("VBS", "REG_MULTI_SZ", "CSCFlags=0\0MaxUses=4294967295\0Path=...")So far, so good. At this point you have split your TSV line into an array.
arrValue = Split(arrFields(0), "=")
REM arrValue = Array("VBS")
strValue = arrValue(0)
REM strValue = "VBS"However, now you're trying to split a string that most likely never will contain a "=" character at that non-existing "=" character. The split will succeed regardless, but it will produce an array with just a single string element. Assigning this element to another variable will produce the exact same result as dropping the split altogether and simply assigning "strValue = arrFields(0)".
arrType = Split(arrFields(1), "=")
REM arrType = Array("REG_MULTI_SZ")
strType = arrType(1)Just like above you split a string at a value that will never be present in that string. However, in this case you try to assign the
second element of an array that contains
only one element, which will raise an "Index out of bounds" error.
arrData = Split(arrFields(2), "=")
REM arrData = Array("CSCFlags", "0\0MaxUses", "4294967295\0Path", ...)
strData = arrData(2)
REM strData = "4294967295\0Path"arrFields(2) does contain "=" characters for a change, so this time you do get an array with multiple elements. However, the string in arrFields(2) consists of multiple key-value pairs separated by Null characters ("\0"). Merely splitting the string at "=" means that most elements in the resulting array will contain the value of the previous key-value pair, the separating "\0", and the key of the current key-value pair. I somehow doubt that this is what you actually want.
One additional note: the following line is rather pointless, because you never assign values to strName, strAddress or strPhone, so all you'll get is a bunch of "","","" lines.
Cant_Code
strNewContent = strNewContent & Chr(34) & strName & Chr(34) & "," & Chr(34) & strAddress & Chr(34) & _
"," & Chr(34) & strPhone & Chr(34) & vbCrLf