nodiaque Posted August 15, 2007 Share Posted August 15, 2007 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.UserNameobjUserName = replace(objUsername,"\","")objUserName = replace(objUsername,"CN=","")strUsername = split(objUsername,",",3)strUser = strUsername(0) + ", " + strUsername(1)Wscript.Echo strUserstrPublic = "\\srvfich1\Public\" + strUserstrDepot = "\\srvfich1\Depot\" + strUserWscript.echo strPublicWscript.echo strDepotobjNetwork.MapNetworkDrive "w:", strPublicobjNetwork.MapNetworkDrive "x:", strDepotWhile 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 Link to comment Share on other sites More sharing options...
nodiaque Posted August 15, 2007 Author Share Posted August 15, 2007 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èmeSet 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/lerestestrUsername = 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 drivesobjNetwork.MapNetworkDrive "w:", strPublicobjNetwork.MapNetworkDrive "x:", strDepot Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now