map network
Moderator: DosItHelp
-
- Posts: 20
- Joined: 11 Sep 2008 22:36
map network
I am trying to map network and copy files to D:\Backup\Sql_Backup, but I am getting only help
How can I sue this with spaces in my folders
net use R: \\000.00.0.00\Program Files\Microsoft SQL Server\MSSQL\BACKUP"
cd\
echo off
R:
cd \
Xcopy . /D /I /F /E /Y D:\Backup\Sql_Backup
net use R: /delete /y
exit
How can I sue this with spaces in my folders
net use R: \\000.00.0.00\Program Files\Microsoft SQL Server\MSSQL\BACKUP"
cd\
echo off
R:
cd \
Xcopy . /D /I /F /E /Y D:\Backup\Sql_Backup
net use R: /delete /y
exit
-
- Posts: 14
- Joined: 20 Mar 2012 10:07
Re: map network
You have to use double quotes around paths or file names with spaces.
@echo off
net use r: "\\000.00.0.00\Program Files\Microsoft SQL Server\MSSQL\BACKUP"
cd \
R:
Xcopy . /D /I /F /E /Y "D:\Backup\Sql_Backup"
net use r: /delete /y
Not sure why you were CDing to the root of the R: drive, there is no need to when changing drives as specifying only a drive letter will CD you to the root of that drive.
Tony
@echo off
net use r: "\\000.00.0.00\Program Files\Microsoft SQL Server\MSSQL\BACKUP"
cd \
R:
Xcopy . /D /I /F /E /Y "D:\Backup\Sql_Backup"
net use r: /delete /y
Not sure why you were CDing to the root of the R: drive, there is no need to when changing drives as specifying only a drive letter will CD you to the root of that drive.
Tony
Re: map network
tonysathre wrote:Not sure why you were CDing to the root of the R: drive, there is no need to when changing drives as specifying only a drive letter will CD you to the root of that drive.
Actually that's not true Tony, the working directory on a drive can be something other than the root and it will change to the working directory.
If it is the first time the drive is being accessed from a boot then the working directory is the root, and some file managers can be set to always start at the root folder.
Either of these should also work (untested) with the correct IP address in place:
Code: Select all
@echo off
net use r: "\\000.00.0.00\Program Files\Microsoft SQL Server\MSSQL\BACKUP"
pushd "r:\"
Xcopy . /D /I /F /E /Y "D:\Backup\Sql_Backup"
popd
net use r: /delete /y
Code: Select all
@echo off
net use r: "\\000.00.0.00\Program Files\Microsoft SQL Server\MSSQL\BACKUP"
Xcopy /D /I /F /E /Y "R:\*.*" "D:\Backup\Sql_Backup"
net use r: /delete /y
-
- Posts: 14
- Joined: 20 Mar 2012 10:07
Re: map network
That's true, but considering he was mapping the drive, I assumed it would have been the first time the drive was accessed.
Tony
Tony
Re: map network
tonysathre wrote:That's true, but considering he was mapping the drive, I assumed it would have been the first time the drive was accessed.
That's a fair comment - unless the drive was already mapped, I guess.
Re: map network
I thought xcopy could use UNC paths so why bother doing the drive mapping?
But you could also use the pushd with the unc path and then use the xcopy command after that.
But you could also use the pushd with the unc path and then use the xcopy command after that.
-
- Posts: 20
- Joined: 11 Sep 2008 22:36
Re: map network
Thanks to all of You, It is working.
Re: map network
Squashman wrote:I thought xcopy could use UNC paths so why bother doing the drive mapping?
But you could also use the pushd with the unc path and then use the xcopy command after that.
Thanks for that info. I'd never tried it so wasn't aware.
So both of these should work (with the correct IP address):
Code: Select all
@echo off
pushd "\\000.00.0.00\Program Files\Microsoft SQL Server\MSSQL\BACKUP"
Xcopy /D /I /F /E /Y . "D:\Backup\Sql_Backup"
popd
Code: Select all
@echo off
xcopy /D /I /F /E /Y "\\000.00.0.00\Program Files\Microsoft SQL Server\MSSQL\BACKUP\*.*" "D:\Backup\Sql_Backup\"