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
Add variable to drive mapping script
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.
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.
- mmacdonald
- Posts: 44
- Last visit: Thu Apr 07, 2016 7:53 am
Add variable to drive mapping script
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
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
- jdelatorre@hfinc.com
- Posts: 54
- Last visit: Wed Jan 30, 2008 1:42 am
Add variable to drive mapping script
"CAMSSAF002GOR01HOME1XEROX_SCANSCW_SCANDATAUSERS" & objNetwork.UserName
- mmacdonald
- Posts: 44
- Last visit: Thu Apr 07, 2016 7:53 am
Add variable to drive mapping script
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.
- mmacdonald
- Posts: 44
- Last visit: Thu Apr 07, 2016 7:53 am
Add variable to drive mapping script
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.
Thanks.
- mmacdonald
- Posts: 44
- Last visit: Thu Apr 07, 2016 7:53 am
Add variable to drive mapping script
I found syntax that seems to work for me.
objNetwork.MapNetworkDrive "X:", "serversharefolderfolderUSERS" & "" & objNetwork.UserName
Thank you to everyone for the pointers.
objNetwork.MapNetworkDrive "X:", "serversharefolderfolderUSERS" & "" & objNetwork.UserName
Thank you to everyone for the pointers.