Hi,

I am trying to write a script which will help map a users network drive
on logon. It requires me to separate the username into 3 parts.

For example:-
if the username is abc123

The network drive address would be \\serveraddress\users\a\b\abc123

I am using vbs to write this script and have gotten this far -

Run "net use u: \\serveraddress\users\" & oNetwork.UserName & "
/persistent:no"

Does anyone know how I can get about doing this? Thanks.


Dikshant

Re: Separating characters from username by joseomjr

joseomjr
Mon Jul 10 14:16:49 CDT 2006

oNetwork.UserName in your example would return abc123 so you could do
something like this

UserName = oNetwork.UserName
str1 = Left(Username, 1)
str2 = Mid(Username, 2, 1)
path = "serveraddress\users\" & str1 & "\" & str2 & "\" & UserName

Run "net user u: " & path & " /persistent:no"

before you do the run do a wscript.echo of the variable path to make
sure it is what you want.

dikshantd@gmail.com wrote:
> Hi,
>
> I am trying to write a script which will help map a users network drive
> on logon. It requires me to separate the username into 3 parts.
>
> For example:-
> if the username is abc123
>
> The network drive address would be \\serveraddress\users\a\b\abc123
>
> I am using vbs to write this script and have gotten this far -
>
> Run "net use u: \\serveraddress\users\" & oNetwork.UserName & "
> /persistent:no"
>
> Does anyone know how I can get about doing this? Thanks.
>
>
> Dikshant


Re: Separating characters from username by Richard

Richard
Mon Jul 10 14:16:00 CDT 2006

Dikshant wrote:

> I am trying to write a script which will help map a users network drive
> on logon. It requires me to separate the username into 3 parts.
>
> For example:-
> if the username is abc123
>
> The network drive address would be \\serveraddress\users\a\b\abc123
>
> I am using vbs to write this script and have gotten this far -
>
> Run "net use u: \\serveraddress\users\" & oNetwork.UserName & "
> /persistent:no"
>
> Does anyone know how I can get about doing this? Thanks.

Hi,

You can use VBScript string functions like Mid, Left, Right, and InStr to
parse username. For example:

strUser = oNetwork.UserName
strShare = "\\serveraddress\users\" & Left(strUser, 1) & "\" & Mid(strUser,
2, 1) & "\" & strUser

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net