开发者

Batch file to map a drive when the folder name contains spaces

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. Th开发者_C百科e 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.


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?


whenever you deal with spaces in filenames, use quotes

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


I'm not sure this will help you to much by I once needed a batch file to open a game, the .exe was in a folder with blanks (duh!) and I tried : START "C:\Fold 1\fold 2\game.exe" and START C:\Fold 1\fold 2\game.exe - None worked, then I tried

   START C:\"Fold 1"\"fold 2"\game.exe and it worked 

Hope it helps :)


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

does not work?


net use f: \\\VFServer"\HQ Publications" /persistent:yes

Note that the first quotation mark goes before the leading \ and the second goes after the end of the folder name.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜