Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 



nodiaque

Map drive on logon

Recommended Posts

nodiaque    0

Hello everyone, I have a little problem.

I'm working in a 2000/xp environnement with a windows 2003 server running Active Directory. Now when user logon, there home directory automaticly map to Z. But I have 2 more drive to map so I made a little script for that:

Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")

objUsername = objSysInfo.UserName
objUserName = replace(objUsername,"\","")
objUserName = replace(objUsername,"CN=","")
strUsername = split(objUsername,",",3)
strUser = strUsername(0) + ", " + strUsername(1)
Wscript.Echo strUser

strPublic = "\\srvfich1\Public\" + strUser
strDepot = "\\srvfich1\Depot\" + strUser

Wscript.echo strPublic
Wscript.echo strDepot


objNetwork.MapNetworkDrive "w:", strPublic
objNetwork.MapNetworkDrive "x:", strDepot

While it work fine, the problem I have is that most of users have spaces in the drive to map (like \\srvfich1\Public\Raoul, Alfonse). because of the space, it then try to map "\\srvfich1\Public\Raoul,".

Do you have any way arround this? I can't rename the folder so it have to map to this name.

Thanks

Share this post


Link to post
Share on other sites

nodiaque    0

Fixed it myself. I cleaned up the code and put some comments, but it's in french (sorry, for a french environnement)

'########################################################################################
'# #
'# Script: Map Drive Depot Public #
'# Auteur: Jean-Sébastien Frenette #
'# Système: Active Directory #
'# Description: Va chercher le full name sur AD de l'usagé connecté et map #
'# Depot sur "x:" et Public sur "w:" #
'########################################################################################



'On crée les connections vers le système
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")

'On va chercher le fullpath du user connecté
objUsername = objSysInfo.UserName

'On enlève le \ devant la ,
objUserName = replace(objUsername,"\","")

'On enlève le CN=
objUserName = replace(objUsername,"CN=","")

'On split en 3 partit, lastname/firstname/lereste
strUsername = split(objUsername,",",3)

'On set les noms des mappings
'Trim est TRÈS IMPORTANT, sinon le mapping marche pas (caractère non imprimable donc invisble)
strPublic = "\\srvfich1\Public\" + trim(strUsername(0)) + ", " + trim(strUsername(1))
strDepot = "\\srvfich1\Depot\" + trim(strUsername(0)) + ", " + trim(strUsername(1))

'On map les drives
objNetwork.MapNetworkDrive "w:", strPublic
objNetwork.MapNetworkDrive "x:", strDepot

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.

×