Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Batch file Windows 7 - Copying from \\sharename

Posted on 2014-03-07
11
Medium Priority
?
1,906 Views
Last Modified: 2014-03-07
I used to have a simple batch file we would run in our Windows XP environment that no longer works in Windows 7.  I've tried changing the batch file, but still can't get it working.  All this batch file does is copy about 6 files from a network share and place them in various locations on the C: drive.  For example, each line says something like:

copy \\sharename\install\file1.txt c:\test  (this would copy the file "file1.txt" in my \\share\install folder to the folder called "test" on my c: drive)

For some reason in Windows 7, UNC paths with the \\ don't seem to work in batch files any more.  So, my solution was to do a temporary drive map to the network share at the beginning of the batch file, then disconnect the drive mapping at the end of the batch file.  So at the beginning of my batch file, I put in:

net use g: \\sharename\install

But, I get a "System error 3 has occurred" when I run the script.

First question:  Why is the behavior of such a simple batch file different in Windows 7 compared to Windows XP?

Second question:  Why am I getting system error 3 when trying to map a drive?
0
Comment
Question by:jbobst
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 71

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39913232
UNC paths still work. Note that it is \\server\share, not \\share .
0
 
LVL 34

Assisted Solution

by:Paul MacDonald
Paul MacDonald earned 500 total points
ID: 39913244
To add to what [Qlemo] said, is the batch file on the Windows 7 machine running under the same account as the batch file on the Windows XP machine?  This could be a permissions issue.
0
 
LVL 13

Assisted Solution

by:Santosh Gupta
Santosh Gupta earned 500 total points
ID: 39913246
Try running at an elevated command prompt.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:jbobst
ID: 39913247
Sorry, I do have the \\servername\sharename in the real script.  And, they don't work.
0
 
LVL 1

Author Comment

by:jbobst
ID: 39913249
I've tried running as administrator, doesn't work either.
0
 

Assisted Solution

by:Ins0mniac81
Ins0mniac81 earned 500 total points
ID: 39913267
I've needed to put network locations in quotations in my scripts, you might try that.
"\\server\sharename"
0
 
LVL 1

Author Comment

by:jbobst
ID: 39913268
All of the our domain user accounts are local admins (just as they were with XP) and it still doesn't work even when running the script with admin rights.
0
 
LVL 1

Author Comment

by:jbobst
ID: 39913281
I am an idiot....there was a simply syntax error in my batch file.  A folder name had a space in it and the batch file had no space.  I am very sorry for wasting everyone's time.  Thanks for the help!
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39913336
BTW if you do need to do something with a mapped drive pushd and popd are useful:

@echo off
pushd "\\server\share\path"
echo Now you are on a temporary drive mapping to above share, generally Z:
echo Path is %cd%
popd
echo Now the temporary drive has gone.
0
 
LVL 25

Expert Comment

by:Mohammed Khawaja
ID: 39913766
first of all net use command should be as following:

net use x: \\servername\sharename

System error 3 refers to path not found

Are you able to see the shares on the server if you run "net view \\servername" and if you can then does the command "dir \\servername\sharename" shows you the content of the share.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39913821
mnkhawaja - he has already solved problem, just spaces in the path;
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
While working, an annoying popup showing below will come and we cannot cancel or close it form the screen. The error message will come again and again.
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.
Suggested Courses

664 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