Add variable to drive mapping script

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
mmacdonald
Posts: 44
Joined: Fri Jan 11, 2008 2:58 am

Add variable to drive mapping script

Post by mmacdonald »

Greetings:

I am very new to VB and need a pointer on solving a small problem. I have a requirement to map a drive to a folder that has the user's name as the folder name. I would like to be able to use the logged in user name for the mapping to the folder.

The script I am using looks like this:

Set objNetwork = CreateObject("Wscript.Network")Set objSysInfo = CreateObject("ADSystemInfo")
strUserPath = "LDAP://" & objSysInfo.UserNameSet objUser = GetObject(strUserPath)
For Each strGroup in objUser.MemberOf strGroupPath = "LDAP://" & strGroup Set objGroup = GetObject(strGroupPath) strGroupName = objGroup.CN Select Case strGroupName

Case "GOR-G_XeroxScannerAccess-DLG" objNetwork.MapNetworkDrive "X:", "CAMSSAF002GOR01HOME1XEROX_SCANSCW_SCANDATAUSERS<user_name_folder_goes_here>"

End SelectNext

User avatar
mmacdonald
Posts: 44
Joined: Fri Jan 11, 2008 2:58 am

Add variable to drive mapping script

Post by mmacdonald »

Greetings:

I am very new to VB and need a pointer on solving a small problem. I have a requirement to map a drive to a folder that has the user's name as the folder name. I would like to be able to use the logged in user name for the mapping to the folder.

The script I am using looks like this:

Set objNetwork = CreateObject("Wscript.Network")Set objSysInfo = CreateObject("ADSystemInfo")
strUserPath = "LDAP://" & objSysInfo.UserNameSet objUser = GetObject(strUserPath)
For Each strGroup in objUser.MemberOf strGroupPath = "LDAP://" & strGroup Set objGroup = GetObject(strGroupPath) strGroupName = objGroup.CN Select Case strGroupName

Case "GOR-G_XeroxScannerAccess-DLG" objNetwork.MapNetworkDrive "X:", "CAMSSAF002GOR01HOME1XEROX_SCANSCW_SCANDATAUSERS<user_name_folder_goes_here>"

End SelectNext

User avatar
jdelatorre@hfinc.com
Posts: 54
Joined: Mon Sep 10, 2007 2:26 am

Add variable to drive mapping script

Post by jdelatorre@hfinc.com »

"CAMSSAF002GOR01HOME1XEROX_SCANSCW_SCANDATAUSERS" & objNetwork.UserName

User avatar
mmacdonald
Posts: 44
Joined: Fri Jan 11, 2008 2:58 am

Add variable to drive mapping script

Post by mmacdonald »

This did not work using the command syntax shown in the example. I am thinking I need to get some quotes in the line somewhere.

User avatar
mmacdonald
Posts: 44
Joined: Fri Jan 11, 2008 2:58 am

Add variable to drive mapping script

Post by mmacdonald »

I have tested this by using the same folder structure and the net use command. Everything works fine. If I remove the "& objNetwork.UserName " and insert the real account name in its place, the script will map correctly. I'll have to keep tinkering. If anyone can think of anything to try, please create a post.
Thanks.

User avatar
mmacdonald
Posts: 44
Joined: Fri Jan 11, 2008 2:58 am

Add variable to drive mapping script

Post by mmacdonald »

I found syntax that seems to work for me.
objNetwork.MapNetworkDrive "X:", "serversharefolderfolderUSERS" & "" & objNetwork.UserName

Thank you to everyone for the pointers.

Locked