How to automate pressing the enter key

I'll start this off by saying I have next to no experience in writing batch files.

Here is the text of a simple batch file that I'm hoping to modify.  The batch file works correctly, but you have to press the enter key to perform the action and you have to press it again when it's finished.  What I want to do (not sure if it's possible) is to change the batch file so someone does not have to press enter, they simply double click on the batch file and it runs to completion.  Can that be done and if so, can someone teach me how?  I did not write this batch file, I just inherited it and changed the pathways as a test.

"ECHO OFF
prompt
REM
REM
REM

PAUSE

   COPY  C:\users\wrehn\documents\cr131211.xlsx C:\user\wrehn\documents\newfolder\*.*
 
  
PAUSE"

January 10th, 2014 7:49pm

Can that be done and if so, can someone teach me how?

Getting rid of the Pause statement would cause the batch file to end by itself. You should also add the /Y switch to the copy command so that the target file is overwritten without prompting the user.
  • Proposed as answer by FZB Friday, January 10, 2014 5:07 PM
  • Marked as answer by Bill_StewartModerator Friday, January 10, 2014 5:08 PM
Free Windows Admin Tool Kit Click here and download it now
January 10th, 2014 7:53pm

expanding on that same logic, I removed both pauses and now it does run without having to press enter at the beginning or the end.  I haven't added the /Y yet, but I don't get a message about overwriting the existing file.  For this sample, it's not important, but I will remember that for down the road.  Thank you so much!
January 10th, 2014 8:00pm

expanding on that same logic, I removed both pauses and now it does run without having to press enter at the beginning or the end.  I haven't added the /Y yet, but I don't get a message about overwriting the existing file.  For this sample, it's not important, but I will remember that for down the road.  Thank you so much!

Thanks for the feedback. Note also that
"echo off
should read
@echo off

The prompt instruction serves no purpose.

Free Windows Admin Tool Kit Click here and download it now
January 10th, 2014 8:08pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics