Solved

map a network drive in a bat file

Posted on 2014-11-24
7
161 Views
Last Modified: 2014-11-24
Hi,

I want to be able to map a network path on my windows server with a simple bat file.

The easy command I use is this:
net use o: \\Pbtuk-639-02-13
move /-y "D:\production\*.*" "o:\e\AV Media\"
pause

Open in new window

However I get this error message when executing the file:
Net use
I have done a net view and then it was no problem to find the network path.
Net view
From what I understand the computer is shared with Everyone.

Thanks for help!

Peter
0
Comment
Question by:peternordberg
7 Comments
 
LVL 3

Expert Comment

by:Barry Molenwijk
Comment Utility
If you go to O: in your command prompt and do a dir, do you see everything you're supposed to see?
0
 
LVL 82

Expert Comment

by:oBdA
Comment Utility
Remove the trailing backslash in your target path for the move command:
move /-y "D:\production\*.*" "o:\e\AV Media"

Open in new window

0
 
LVL 15

Expert Comment

by:Perarduaadastra
Comment Utility
I think the clue is in the error...

When you set up a network share, the UNC pathname should include the name of the host, and the target folder. You seem to be missing part of the pathname. It should look like this:

\\hostname\foldername

Don't forget that the folder itself must be shared and have the correct permissions.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 4

Expert Comment

by:DataPro
Comment Utility
Peraduaadastra is exactly right, you need the host and share name to map a drive.  Fix that first.
0
 

Author Comment

by:peternordberg
Comment Utility
Hi,

I changed it like this now:
net use o: "\\Pbtuk-639-02-13e\AV Media"
move /-y "D:\production\*.*" "o:\"
pause

Open in new window


But I get this error:
 bat4.png
Thanks for help!

Peter
0
 
LVL 82

Accepted Solution

by:
oBdA earned 250 total points
Comment Utility
Try
net use o: "\\Pbtuk-639-02-13\e"
move /-y "D:\production\*.*" "o:\AV Media"
pause

Open in new window

0
 
LVL 15

Assisted Solution

by:Perarduaadastra
Perarduaadastra earned 250 total points
Comment Utility
Get rid of the space in the pathname. Instead of AV Media, use AVMedia, AV-Media, or AV_Media...

I notice that you put quotes around the net use argument, but I don't think that works for pathnames - at least, I've never seen it used.
0

Featured Post

Want to promote your upcoming event?

Are you going to an event? Are you going to be exhibiting at a tradeshow? Talking at a conference? Using a promotional banner in your email signature ensures that your organization’s most important contacts stay in the know and can potentially spread the word about the event.

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
In this Micro Tutorial viewers will learn how they can get their files copied out from their unbootable system without need to use recovery services. As an example non-bootable Windows 2012R2 installation is used which has boot problems.
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now