
Re: Batch file to attach remote shared drive and copy file?
cool thanks, I will try this when I'm at work on Monday, unfortunately I am unable to now as I don't have access to the network.
Just a few questions:
1.) Can the code that you posted above can just totally replace mine? I don't need to use the "NET USE" way of doing it?
2.) Will this work on a Windows Server 2003 platform (the local and remote servers both being Win 2003).
3.) Why is "2>nul" there?
4.) I need to do this for quite a few servers, but if I just copy paste this code in the batch file for each server, and edit it to contain the specific servers name, then it should be fine? (I know some kind of loop would be better, where the servernames are read in from another file but I just want to get this working first)
5.) I think the account I will be using on the local box (where I will run the batch file) will be allowed to access the remote folder, however, just in case it isn't, can you specify a username and password with your way of doing things? If so, how would I do this? I think you can with "NET USE".
6.) Your way of doing it isn't really mapping a drive is it? because the share is just made to be the current directory, its not like another drive letter would appear on the local box and when clicked I would see the contents of the shared folder on he other server? if this is so then thats fine i think, just trying to understand it.
Below I have just put a few comments for what I think each line in your code does:
Code:
@echo off
md "c:\files" 2>nul REM Sets "c:files" to be the directory where the files will be copied into and stored.
pushd "\\remoteserver\share" REM makes "\\remoteservername\share" the current directory, basically it connects to it.
if exist \*050912.rpt.zip copy \*050912.rpt.zip "c:\files" REM if the file exists then copy it
popd REM stops "\\remote\share" from being the current directory, basically disconnects from it.
I'm grateful for what you have posted, I hope you don't mind my questions, thank you
