views:

398

answers:

3

I am trying to map a drive using a batch file. I have tried:

net use m: \\Server01\myfolder /USER:mynetwork\Administrator "Mypassword" /persistent:yes

It works fine. The problem comes when I try to map a folder with spaces on its name:

net use m: \\Server01\my folder /USER:mynetwork\Administrator "Mypassword" /persistent:yes

I have tried using quotes, using myfold~1 but nothing works.

An easy way would be renaming the folder but I have it mapped in more than 300 workstations so is not a very good idea.

PLEASE HELP!!!

A: 
net use "m:\Server01\my folder" /USER:mynetwork\Administrator "Mypassword" /persistent:yes 

does not work?

Axarydax
net use "m:\Server01\my folder" /USER:mynetwork\Administrator "Mypassword" /persistent:yes doesn't work
Santiago
Why have you got the drive letter as part of the UNC? And why do you still have your April-1 gravatar? :-)
paxdiablo
It was ghostdog74 suggestion. Anyway net use m: "\Server01\my folder" works. Thanks chalup
Santiago
@paxdiablo - 'cause I love it! (the gravatar, not the drive letter)
Axarydax
A: 

whenever you deal with spaces in filenames, use quotes

net use "m:\Server01\my folder" /USER:mynetwork\Administrator "Mypassword" /persistent:yes
ghostdog74
No. It doesn't work
Santiago
Why have you got the drive letter as part of the UNC?
paxdiablo
+2  A: 

I just created some directories, shared them and mapped using:

net use y: "\\mycomputername\folder with spaces"

So this solution gets "works on my machine" certificate. What error code do you get?

chalup
This one worked!!! Thanks a lot!!!
Santiago
@Santiago, the usual behaviour, when an answer solves your problem, is to click on the big honkin' green tick outline to the left to accept said answer (and upvote with the up arrow as well for a bonus). That will reward chalup for the help given, you for accepting an answer, and increase your accept rate from 0 to 100%, making it far more likely that future questions will be answered :-) Cheers and welcome to SO.
paxdiablo