Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1930
  • Last Modified:

Batch file Windows 7 - Copying from \\sharename

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
jbobst
Asked:
jbobst
4 Solutions
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
UNC paths still work. Note that it is \\server\share, not \\share .
0
 
Paul MacDonaldDirector, Information SystemsCommented:
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
 
Santosh GuptaCommented:
Try running at an elevated command prompt.
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
jbobstAuthor Commented:
Sorry, I do have the \\servername\sharename in the real script.  And, they don't work.
0
 
jbobstAuthor Commented:
I've tried running as administrator, doesn't work either.
0
 
Ins0mniac81Commented:
I've needed to put network locations in quotations in my scripts, you might try that.
"\\server\sharename"
0
 
jbobstAuthor Commented:
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
 
jbobstAuthor Commented:
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
 
Steve KnightIT ConsultancyCommented:
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
 
Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
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
 
Steve KnightIT ConsultancyCommented:
mnkhawaja - he has already solved problem, just spaces in the path;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now