×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Network Drive Label

Network Drive Label

Network Drive Label

(OP)
Hello all,

I am having a bit of a problem trying to rename mapped network drives. We use a .bat logon script that maps our network drives using net use and then the batch script calls a vbscript that renames the network drives. The script vbscript looks like:

Set oShell = CreateObject("Shell.Application")
oShell.NameSpace("H:\").Self.Name = "Home"
oShell.NameSpace("I:\").Self.Name = "ProgramFiles"
oShell.NameSpace("P:\").Self.Name = "Public"
oShell.NameSpace("X:\").Self.Name = "Apps"

The problem is that we now would like to label the H: Drive with the %username% variable, so it shows the user's logon name. So for example Sue Water's H: Drive would show up as waterss (H:) in My Computer. How would I go about doing this?

RE: Network Drive Label

(OP)
Thanks for the reply. So in this case, what would my whole VBScript look like?

RE: Network Drive Label

Assuming your initial code worked and made the H: drive show up as Home (H:), then this should work (not tested):

CODE

Set wshShell = CreateObject( "WScript.Shell" )
username = wshShell.ExpandEnvironmentStrings( "%username%" )

Set oShell = CreateObject("Shell.Application")
oShell.NameSpace("H:\").Self.Name = username
oShell.NameSpace("I:\").Self.Name = "ProgramFiles"
oShell.NameSpace("P:\").Self.Name = "Public"
oShell.NameSpace("X:\").Self.Name = "Apps" 

RE: Network Drive Label

(OP)
Perfect!! Thank you so much! This works just as we had hoped. The H: Drive is labeled as the user's logon username. Thanks a million!bigsmile

RE: Network Drive Label

You're welcome, glad it helped.

RE: Network Drive Label

Neaxman, don't forget to click the Great Post link to give a star to Guitarzan's post.

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

RE: Network Drive Label

Given that users can modify environment variables, why not go with:

CODE

Set wshNetwork = CreateObject("WScript.Network")
username =  wshNetwork.UserName 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close