VBScript Drive Mapping Question

I need to map a drive letter to a local folder (C:\temp) in order for one of our document management programs to function.  I need to do this in a vbscript and it has always been in autoit in the past. Can someone point me in the right direction.  I have tried using a normal mapping but that does not work. Any ideas?  Thanks..
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.

Hi, why would you need to map a drive to a local folder?

If you really need to do that, try this:
Set objShell = CreateObject("WScript.Shell")
strDrive = "X:"
strPath = "C:\Temp"
objShell.Run "cmd /c SUBST " & strDrive & " " & strPath, 1, True

Or, if it's a network share:
Set objNetwork = CreateObject("WScript.Network")
strDrive = "X:"
strPath = "\\server\share"
objNetwork.MapNetworkDrive strDrive, strPath

These are both VBS scripts, by the way.



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
TheITGuyAuthor Commented:
I will give it a shot when I get in tomorrow morning.  We are running Documentum 5 for our document management system and it requires this for a temp folder.  I am sure we could do it some other way but this is the way they set it up originally so we are stuck with it for now.  Either way I will give it a go in the morning and let you know.  Thanks for the input.
Hmmm, does it need to be a "drive letter" to a local folder (in which case SUBST will do the job), or does it need an environment variable set to it, like the way %temp% works (In DOS type: echo %temp%)?

Anyway, try out what I posted, and see how you go?


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
VB Script

From novice to tech pro — start learning today.