Avatar of Aleks
Aleks
Flag for United States of America asked on

Problem with .bat program copying files

I have a .bat program which copies files from one hard drive to another, it reads:

---
@echo off

echo Starting backup process...

xCopy /E/Y C:\BDotAttachments\*.*  E:\BDotDesktopBkp\BDotAttachments

if %errorlevel% gtr 0 (
  echo ERROR [%errorlevel%]: Backup process completed but with error(s).
) else (
  echo Backup process completed successfully.
)

pause
---

But when I run it I get the error attached. Please advice.
Capture.PNG
Windows OSProgrammingStorage Software

Avatar of undefined
Last Comment
Qlemo

8/22/2022 - Mon
NVIT

Add the /i switch so you don't get the prompt and it makes the directory automatically
Aleks

ASKER
thx .. seems to work. isn't 'pause' supposed to keep the window open at the end ?  it closes :$
ASKER CERTIFIED SOLUTION
Qlemo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23