Solved Batch to map to network folder

Dell / Latitude e6420
April 22, 2013 at 05:55:03
Specs: Win 7 Pro x64, I7 Sandy Bridge 2.201 GHz / 8072 MB
How can I map to a specific network folder only if it exists, if not exit. I would like to do this in a batch file. Currently this script hangs and will not finish. I thought this could work using IF ELSE. Perhaps somebody better versed in batch can help me fix this.

If exist \\servername\Users\%username%
(NET USE U: \\servername\Users\%username% /PERSISTENT:YES)
Else
(Exit)
Best Regards,
~winipcfg

ASCII question, get an ANSI


See More: Batch to map to network folder

Report •


#1
April 22, 2013 at 06:28:31
✔ Best Answer
Try the following

pushd \\servername\Users\%username% 2>nul || exit
popd
net use U: \\servername\Users\%username% /persistent:YES


Report •

#2
April 22, 2013 at 06:46:22
IVO,
Unfortunately that did not work. Any other ideas?
~winipcfg

ASCII question, get an ANSI


Report •

#3
April 22, 2013 at 06:48:04
Obvious question not answered: Why is it hanging?

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
April 22, 2013 at 06:54:02
IVO,
I spoke too soon. That DID work! Thanks!!
Best regards,
~winipcfg

ASCII question, get an ANSI


Report •


Ask Question