Another Batch Files question

Egg 'n' Bacon
5StarLounger
Posts: 736
Joined: 18 Mar 2010, 11:05

Another Batch Files question

Post by Egg 'n' Bacon »

I've got the Batch below I run occasionally, that I borrowed from somewhere., I'd just like it to pause at the end (or close on a key press) so I can see if a file has been copied over.

Code: Select all

@ECHO OFF
ECHO You are about to update files etc.
ECHO Close all applications that use these files.
SET /P var=Type Y to continue, N to stop.
IF %var% == N GOTO No
IF %var% == n GOTO No
xcopy "F:\ISO9001 2000 QMS\Archive Folder\QA\QMS\Obsolete Forms\INDEX of Controlled Change.xls" "G:\Forms\XLFiles\INDEX of Controlled Change.xls" /D /e /v /r /k /y
:No
xcopy "G:\Forms\XLFiles\INDEX of Controlled Change.xls" "G:\CZ\Forms\XLFiles\INDEX of Controlled Change.xls" /D /e /v /r /k /y
TIA

User avatar
HansV
Administrator
Posts: 78394
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Another Batch Files question

Post by HansV »

Put a line

pause

at the end. It'll display a message

Press any key to continue...
Best wishes,
Hans

Egg 'n' Bacon
5StarLounger
Posts: 736
Joined: 18 Mar 2010, 11:05

Re: Another Batch Files question

Post by Egg 'n' Bacon »

As simple as that.

Thank you

User avatar
John Gray
PlatinumLounger
Posts: 5405
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Another Batch Files question

Post by John Gray »

You could save a line by putting the single line
IF /i "%var%"=="n" GOTO No
instead of testing separately for upper- and lower-case 'n', and this format with double quotes solves the problem of the user just pressing Enter!
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...