Link to home
Start Free TrialLog in
Avatar of CEHJ
CEHJFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Backup batch file

This should be pretty easy but the combinations i've tried don't cut it. I want to


a. start a backup app using apache Ant with Start|Run|Backup
b. Have the backup run and print a message telling the user to close the window afterwards

I tried the following, but the window didn't remain
:: Run a backup
ant -f backup.xml backup
echo You can close this window now
pause

Open in new window

Avatar of sjklein42
sjklein42
Flag of United States of America image

How are  you firing off the batch job?  From the Task Scheduler, or from double-clicking an icon, or what?  If from the Task Scheduler, is "Run only if logged on" checked?
Avatar of CEHJ

ASKER

>>How are  you firing off the batch job?

>>start a backup app using apache Ant with Start|Run|Backup
If I understand your original problem, it is that the "pause" statement is not actually pausing.  Is this right?

I also think there was a small confusion about my previous question.  The four lines of code you posted above - are they in a batch file?  Like a file called "runbackup.bat"?  That's the batch job I was asking about.  If so, how are you starting it?  From the command line, double-click an icon, or what?

As an experiment, if you temporarily get rid of the ANT line, does the batch job pause the way you want it to?  Of course it will not have done the backup, but does the pause work?

:: Run a backup
echo You can close this window now
pause 

Open in new window

Avatar of CEHJ

ASKER

>> The four lines of code you posted above - are they in a batch file?  Like a file called "runbackup.bat"?  

Yes

>> If so, how are you starting it?  From the command line, double-click an icon, or what?

>> with Start|Run|Backup

>> but does the pause work?

Can't test now, but, afaicr, no
Works for me (but isn't that always the way).  Gotta be something simple we're missing.

First of all, make sure that "pause" works for you from a DOS command window.

If that works, then make a new batch file "pauseme.bat" (don't call it "pause.bat") with just the "pause" command. Does pauseme.bat properly pause when you run it from Start/Run (pauseme)?  If not, what does it do when you run it in a DOS command window?

As an aside, using "::" for a comment (is that what you're doing?) is not advisable.  I think you should be using REM.

pauseme.bat:
REM Run a backup
echo You can close this window now
pause

Open in new window


Avatar of CEHJ

ASKER

I don't know why but the pause thing has something to do with the way Ant runs. As soon as the ant command is added into the mix, then pause has no effect and the window disappears when the ant has finished. Possibly something to do with the fact that ant itself starts with a batch file.

The workaround is to use the Ant <input> element
Avatar of CEHJ

ASKER

If you can look into my theory (and you feel like doing so) i will gladly award maximum points for what could be a useful addition to the EE database
ASKER CERTIFIED SOLUTION
Avatar of sjklein42
sjklein42
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CEHJ

ASKER

Good - just the confirmation i needed :)