I need to do copies/backups between a Windows XP computer, a Win 7 computer and several NAS drives using Batch files. I need to avoid using plain drive letters as there is a possibility a Batch file for one computer may be executed on the wrong computer and overwrite the wrong local drive.
xxcopy "\\127.0.0.1\G$\sample\" "\\NAS1\Volume_1\sample\"
will copy from the current machines G: drive to the NAS, but I want to be able to do
xxcopy "\\Computer1\G$\sample\" "\\NAS1\Volume_1\sample\"
or even
xxcopy "\\Computer1\G$\sample\" "\\Computer2\G$\sample.copy\"
but when I use the computer name - I get 'Remote source not accessible'
You can use the %Computername%
variable for the local computer.
xxcopy "\\%Computername%\G$\sample\" "\\NAS1\Volume_1\sample\"
If you extract the %Computername%
variables from all your machines then you can hard code them into your backups scripts.