Start /w does not continue

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
jpalik
Posts: 8
Joined: 01 Feb 2016 06:45

Start /w does not continue

#1 Post by jpalik » 01 Feb 2016 08:07

I am not a programmer, however I am a technical writer and understand "some" code.

I am running a simple batch file that uses START /w to start a cmd file. It is important that the file finished before it continues executing the batch file. Start /w stops the batch file from continuing but it does not recognize when the cmd is finished. Consequently, The batch file is never continued.

I have tried START /w and START /wait. Neither works.
How do I make the batch file understand when the cmd file is done.

This batch file is intended to start a series of backup programs and record the time and date that each backup was completed by creating an empty folder at the top of each directory backed up. It is important the the empty directory is not created until the backup is finished.

Code: Select all

ECHO ON
CD /d C:\Temp
RD "$LAST BACKED UP"
MD "$LAST BACKED UP"
CD /d D:\
RD "$LAST BACKED UP"
MD "$LAST BACKED UP"

REM 00-Backup-JFileSync is the directory where the backup program is located
CD D:\00-Backup-JFileSync

Start /w 00-CTempTest
CD D:\000-BackupTest
RD "$LAST BACKED UP"
MD "$LAST BACKED UP"

CD D:\00-Backup-JFileSync
Start /w 00-BackupTestDtoZ

CD D:\
RD "$LAST BACKUP FINISHED"
MD "$LAST BACKUP FINISHED"


Thank you in advance for your help.

Jim
Last edited by Squashman on 01 Feb 2016 08:18, edited 1 time in total.
Reason: MOD EDIT: Please use code tags

Squashman
Expert
Posts: 4487
Joined: 23 Dec 2011 13:59

Re: Start /w does not continue

#2 Post by Squashman » 01 Feb 2016 08:19

Batch files are sequential processing. In your instance there really is no need to use the START command. Just put the executable file name on a line by itself. If the other programs are actually batch files then use the CALL command.

jpalik
Posts: 8
Joined: 01 Feb 2016 06:45

Re: Start /w does not continue

#3 Post by jpalik » 01 Feb 2016 09:13

Thank you for your help. I just rewrote an new file to test without START. It runs but does not continue the batch file when the executable (LightroomCatalogBackupC-D) was finished. The last RD and MD were not written. everything else worked. See the code below.

Code: Select all

CD /d C:\Lightroom-Catalog
RD "$LAST BACKED UP"
MD "$LAST BACKED UP"

CD /d D:\
RD "$LAST BACKED UP"
MD "$LAST BACKED UP"

CD D:\00-Backup-JFileSync
LightroomCatalogBackupC-D

CD D:\
RD "$LAST BACKUP FINISHED"
MD "$LAST BACKUP FINISHED"


Jim
Last edited by Squashman on 01 Feb 2016 09:16, edited 1 time in total.
Reason: MOD EDIT: Please use code tags

Squashman
Expert
Posts: 4487
Joined: 23 Dec 2011 13:59

Re: Start /w does not continue

#4 Post by Squashman » 01 Feb 2016 09:16

I am not familiar with this program (LightroomCatalogBackupC-D).
Could you give us some background on it?
If you open up a cmd prompt and run it manually does it exit correctly?

jpalik
Posts: 8
Joined: 01 Feb 2016 06:45

Re: Start /w does not continue

#5 Post by jpalik » 01 Feb 2016 09:24

I use a command line backup program called jfilesync. the program allows me to create custom backup routines with user defined names. each routine is a cmd file. LightroomCatalogBackupC-D.cmd it the file name of the custom backup file.

The ultimate goal is to create a set of backup routines in a single batch file without having to call multiple batch files. When each backup routine is completed, an empty folder is created showing the date and time the backup was completed.

I can put the date and time before the backup is started but that defeats the purpose of showing that the backup completed successfully and how long the backup took.
Last edited by jpalik on 01 Feb 2016 09:31, edited 1 time in total.

Squashman
Expert
Posts: 4487
Joined: 23 Dec 2011 13:59

Re: Start /w does not continue

#6 Post by Squashman » 01 Feb 2016 09:30

jpalik wrote:each routine is a cmd file. LightroomCatalogBackupC-D.cmd it the file name of the custom backup file.

And this is what I said about that in my previous reply.
Squashman wrote:If the other programs are actually batch files then use the CALL command.


But that really only answers one of my previous questions. You did not say if the program exits correctly if you run it manually.
If jfilesync is not exiting then you have another problem.

In the future please supply as much detail as possible when describing your problem. You have already not provided information to your original question because you thought it was probably irrelevant. In order to provide a solution, a person needs to know all aspects and scope of a project.

jpalik
Posts: 8
Joined: 01 Feb 2016 06:45

Re: Start /w does not continue

#7 Post by jpalik » 01 Feb 2016 09:38

I'm sorry, I did not answer your full question. Yes, the cmd runs correctly as a stand alone. It also runs correctly in the batch file. It is the remaining part of the batch file that is not executed. Even if I used CALL commands after the file was finished they would probably not be executed. However I have not tried that.

Even then, I want the final date and time to be written to the directory when the backup is finished as it shows in the batch file.

By the way, you are being very helpful.

Jim

Squashman
Expert
Posts: 4487
Joined: 23 Dec 2011 13:59

Re: Start /w does not continue

#8 Post by Squashman » 01 Feb 2016 09:46

If you execute a batch file from another batch file, full control is passed to the batch file you are executing from the first one. In order for control to be passed back to the first batch file you need to use the CALL command to execute a batch file from within another batch file.

We would really need to see the batch files with jfilesync to see if the problem is in there. I would put an ECHO & PAUSE after the jfilesync program to see if it is processing any command after it, and not just hanging on the jfilesync program.

jpalik
Posts: 8
Joined: 01 Feb 2016 06:45

Re: Start /w does not continue

#9 Post by jpalik » 01 Feb 2016 09:53

To answer your question about the jfilesync routine exiting, I opened task manager to monitor what was happening.

1. The batch file opened.
2. The jfilesync backup routine opened
3. When the backup finished the jfile sync closed
3. the batch file remained open.

The backup jfilesync routine is closing according to task manager but the batch file is remaining open and the last three lines are not being executed.

This is what the problem has been all along.

Is there any other information I am not providing for you.

Jim

Squashman
Expert
Posts: 4487
Joined: 23 Dec 2011 13:59

Re: Start /w does not continue

#10 Post by Squashman » 01 Feb 2016 09:57

1. You need to use CALL in your primary batch file.
2. Need to see ALL of the contents of the secondary batch file.

jpalik
Posts: 8
Joined: 01 Feb 2016 06:45

Re: Start /w does not continue

#11 Post by jpalik » 01 Feb 2016 10:10

I did what you suggested. See the following code.

Code: Select all

ECHO

CD /d C:\Lightroom-Catalog

RD "$LAST BACKED UP"

MD "$LAST BACKED UP"

CD /d D:\

RD "$LAST BACKED UP"

MD "$LAST BACKED UP"

CD D:\00-Backup-JFileSync

LightroomCatalogBackupC-D.cmd

Echo Jfile sync finished

Pause

CD D:\

RD "$LAST BACKUP FINISHED"

MD "$LAST BACKUP FINISHED"


Everything before the ...cmd, including the cmd works perfectly. Task manager says the cmd closes but the echo "jfile sync finished and the pause are not executed. the display closes as if the batch file is closed but it still shows as active in task manager.

I have to run an errand for about an hour. I will come back to you then.

Thank you again for your patience and help

Jim
Last edited by Squashman on 01 Feb 2016 10:17, edited 1 time in total.
Reason: MOD EDIT: Please use code tags

Squashman
Expert
Posts: 4487
Joined: 23 Dec 2011 13:59

Re: Start /w does not continue

#12 Post by Squashman » 01 Feb 2016 10:20

No you did not.

1. You still are not using the CALL command.
2. You did not put the ECHO and PAUSE in the correct batch file! It needs to go at the end of this batch file: LightroomCatalogBackupC-D.cmd
3. I asked to see the entire contents of the secondary batchfile: LightroomCatalogBackupC-D.cmd
4. PLEASE USE CODE TAGS! Did you not notice all the previous edits I have done on your posts and the comment I put at the bottom of each.

thefeduke
Posts: 211
Joined: 05 Apr 2015 13:06
Location: MA South Shore, USA

Re: Start /w does not continue

#13 Post by thefeduke » 01 Feb 2016 10:46

jpalik wrote:Everything before the ...cmd, including the cmd works perfectly.
Have you tried?

Code: Select all

CALL LightroomCatalogBackupC-D.cmd
The way you have it, as squashman wrote:
If you execute a batch file from another batch file, full control is passed to the batch file you are executing from the first one. In order for control to be passed back to the first batch file you need to use the CALL command to execute a batch file from within another batch file.
you can expect the script to end there.
John A.

jpalik
Posts: 8
Joined: 01 Feb 2016 06:45

Re: Start /w does not continue

#14 Post by jpalik » 01 Feb 2016 12:14

Hello I am back

Everyone talks about a second batch file. there is no second batch file. This is the only batch file. The purpose of the batch file is

1. to create an empty file that shows the drive was backed up.
2. run the backup routine (which is a cmd file)
3 create another empty file that shows the when the cmd file ended.

One and two work perfectly, three never gets executed because the batch file stops working after the backup routine closes.

The debug statements I entered to show that the backup finished are never displayed and task manager shows that the batch file is still open.

There is no second batch file to call.

What am I missing.

Jim

thefeduke
Posts: 211
Joined: 05 Apr 2015 13:06
Location: MA South Shore, USA

Re: Start /w does not continue

#15 Post by thefeduke » 01 Feb 2016 12:26

jpalik wrote:Everyone talks about a second batch file. there is no second batch file.
Since only two perople have responded, you must mean me. Semantics. Your mythical batch script happens to end with .cmd from an ancient naming convention. Try calling it as suggested.
John A.

Post Reply