VBS - Map Home Directory

We are currently using an SSO kiosk software (Imprivata).  Windows automatically logs into windows using a shared AD account and then locks.  Individual users can then login with their own credentials to run software etc..  The problem is that when each user logs in, they do not have access to their home directory documents folder.  THe shared autologon account maps the AD drive throu GPO as it would for any other account on our network. The SSO software can incorporate VBS scripts during logon/logoff.

I am attempting to map their home directory folder, but having issue.  I can get all the way to the home$ folder, but not the username folder.  Attached is the script I am running.  It seems like there is something the system doesnt like about the %username% variable?

Option Explicit
Dim objNetwork, strRemotePath1
Dim strDriveLetter1
strDriveLetter1 = "M:"
strRemotePath1 = "\\cmc-vserver\home$\%username%"
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1
Wscript.Quit
CMCITDAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITCommented:
See if this helps...

Set oShell = CreateObject( "WScript.Shell" )
user=oShell.ExpandEnvironmentStrings("%UserName%")
strRemotePath1 = "\\cmc-vserver\home$\" & user

Open in new window

0
CMCITDAuthor Commented:
Where would I add that in the current script?  Sorry I am VBS illiterate!
0
NVITCommented:
Option Explicit
Dim objNetwork, strRemotePath1
Dim strDriveLetter1

Set oShell = CreateObject( "WScript.Shell" )

strDriveLetter1 = "M:"
user=oShell.ExpandEnvironmentStrings("%UserName%")
strRemotePath1 = "\\cmc-vserver\home$\" & user
Set objNetwork =CreateObject("WScript.Network")objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1
Wscript.Quit

Open in new window

0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

NVITCommented:
I can't verify that code right now. Try it anyway
0
CMCITDAuthor Commented:
C:\temp\mdrive.vbs(8, 48) Microsoft VBScript compilation error: Expected end of statement
0
NVITCommented:
This works...

Option Explicit
Dim objNetwork, strRemotePath1
Dim strDriveLetter1, user, oShell
Set oShell = CreateObject( "WScript.Shell" )
strDriveLetter1 = "M:"
user = oShell.ExpandEnvironmentStrings("%UserName%")
strRemotePath1 = "\\cmc-vserver\home$\" & user
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1
Wscript.Quit

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CMCITDAuthor Commented:
Thank You!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Software

From novice to tech pro — start learning today.