We help IT Professionals succeed at work.
Get Started

Can I use  computer name.domain instead of the IP address in the path in a cmd file?

Last Modified: 2012-05-11
I have set up a cmd file (attached) that backs up a folder from a local server to a remote server.

I will soon need to change the remote backup location.  The computer at the new location is set up with a dynamic IP and a fixed computer.domain name.   Will the code work if the IP address is replaced with the computer.domain name?

@echo off

:: variables
set drive=\\\Shared$\Backups\TEST
set folder=Test_%date:~10,4%_%date:~4,2%_%date:~7,2%
set backupcmd=xcopy/s/c/d/e/h/i/r/y

md "%drive%\%folder%"

@echo %backupcmd% "C:\shared$\Test1" "%drive%\%folder%"
%backupcmd% "C:\shared$\Test1" "%drive%\%folder%"

echo Backup Complete!

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 19 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE