Torgeir
Mon Feb 09 16:55:57 CST 2004
Andy wrote:
> I have a text file that basically contains one line that reads, as an example:
>
> adduser -u jsmith -n "xxxxxxxxx"
>
> now, what i'd like to do is to be able to make a directory name called jsmith, or whatever username that the text file will contain (as designated after the -u), and create a directory in that name. The username length will vary, but the -n will always appear after the username, and the -u will always appear before the username.
Hi
May ways to do this, here is one:
sTst = "adduser -u jsmith -n ddd"
aLine = Split(sTst)
For i = 0 To UBound(aLine)
If LCase(aLine(i)) = "-u" Then
sName = aLine(i + 1)
Exit For
End If
Next
WScript.Echo sName
' if you risk that there could be more than one space between
' -u and the user name, this will work better
sTst = "adduser -u jsmith -n ddd"
bSwitchIsFound = False ' init value
aLine = Split(sTst)
For i = 0 To UBound(aLine)
If bSwitchIsFound And aLine(i) <> "" Then
sName = aLine(i)
Exit For
ElseIf LCase(aLine(i)) = "-u" Then
bSwitchIsFound = True
End If
Next
WScript.Echo sName
--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter