Avatar of Peter Nordberg
Peter Nordberg
Flag for Sweden asked on

map a network drive in a bat file

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
Windows Server 2012Windows OS

Avatar of undefined
Last Comment
Perarduaadastra

8/22/2022 - Mon
Barry Molenwijk

If you go to O: in your command prompt and do a dir, do you see everything you're supposed to see?
oBdA

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

Open in new window

Perarduaadastra

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.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Jason Johanknecht

Peraduaadastra is exactly right, you need the host and share name to map a drive.  Fix that first.
Peter Nordberg

ASKER
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
ASKER CERTIFIED SOLUTION
oBdA

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.