Unexpected 'Cancel Batch Job' prompts

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Aug 19, 2008
146
0
#1
Going from 13.x to 16.x, have a BTM that's giving me unexpected prompts when run. For now I've reinstalled 13.x side by side to see if it's definitely related to 16.x.

:sub0
echo Moving files in %_cwd...
for %x in (*.jpg) gosub sub1
return
:sub1
if not exist "f:\Archive - NS\%@word["\",2-3,%_cwd]\%@year[%@filedate[%x]]\%@month[%@filedate[%x]]" md /s "f:\Archive - NS\%@word["\",2-3,%_cwd]\%@year[%@filedate[%x]]\%@month[%@filedate[%x]]"
move %x "f:\Archive - NS\%@word["\",2-3,%_cwd]\%@year[%@filedate[%x]]\%@month[%@filedate[%x]]"
return


When executed, I get several of these...

Cancel batch job C:\bin\movesnaps-NS.btm ? (Y/N/A) : N

I answer N, the job continues. In a few seconds I'll get it again. This is running at 3am when no one is at they keyboard.

The prompts occur at the same point each time.

Any ideas?
 
Last edited:
#2
I don't know about the prompts, but you should also be getting errors because of the first "return". There, you're not in a subroutine, so there's nothing to return from. You should see the "Missing GOSUB" message. Use QUIT instead.
 
#3
Going from 13.x to 16.x, have a BTM that's giving me unexpected prompts when run. For now I've reinstalled 13.x side by side to see if it's definitely related to 16.x.

echo Moving files in %_cwd...
for %x in (*.jpg) gosub sub1
return
:sub1
if not exist "f:\Archive - NS\%@word["\",2-3,%_cwd]\%@year[%@filedate[%x]]\%@month[%@filedate[%x]]" md /s "f:\Archive - NS\%@word["\",2-3,%_cwd]\%@year[%@filedate[%x]]\%@month[%@filedate[%x]]"
move %x "f:\Archive - NS\%@word["\",2-3,%_cwd]\%@year[%@filedate[%x]]\%@month[%@filedate[%x]]"
return


[omitted...]
Why not remove the IF NOT EXIST test and just use

MOVE /MD /R %x "f:\Archive - NS\%@word["\",2-3,%_cwd]\%@year[%@filedate[%x]]\%@month[%@filedate[%x]]"\

???
 
Aug 19, 2008
146
0
#4
I don't know about the prompts, but you should also be getting errors because of the first "return". There, you're not in a subroutine, so there's nothing to return from. You should see the "Missing GOSUB" message. Use QUIT instead.
My bad, that's just a snippet of the entire BTM and I left out a key part :-) - now edited.
 
Aug 19, 2008
146
0
#5
Why not remove the IF NOT EXIST test and just use

MOVE /MD /R %x "f:\Archive - NS\%@word["\",2-3,%_cwd]\%@year[%@filedate[%x]]\%@month[%@filedate[%x]]"\

???
Will MOVE /MD create any sub folders like MD /S ?

Let's say the folder \garage\2014 exists. On 1/1 I'll need \garage\2015\1.
 
Aug 19, 2008
146
0
#6
More weirdness, I'm moving a bunch of JPG's from a folder populated via the cloud to another folder structure on the same drive and stored in folders based on the year/month of the JPG.

So I've got two different repositories that get populated and running the BTM on one doesn't exhibit the problem whereas it does consistently at the exact same point when moving from the other path.

Currently both paths are just empty folders since the population takes place over night. So it quickly runs through the paths with nothing to do. One path causes the batch to present the Cancel Batch Job message, the other doesn't. The BTM is run separately for each path.

Presumably the mechanism that looks for Ctrl-C is seeing that while the job is running - and that's the only circumstance in which that message would be displayed?
 
#7
I imagine other signals (than Ctrl-C) could trigger the prompt. When this is running at night, is there any hibernating or similar inactivity going on? Is the job a scheduled task ... or something that might trigger a logoff of the user owning the process?
 
Aug 19, 2008
146
0
#8
I think I've got it working. The part of the BTM above the subroutines above is just a bunch of hard coded CD <some_path>. This batch file originated long ago. I should re-write it to just process what folders are there instead of maintaining the list. In the beginning, there were only two folders :-)

Back to my issue. Turns out, one of the paths I was CD'ing to did not exist.

When running the batch file...

TC11 - reports the path does not exist and identifies the line in the batch file containing the CD command
TC13 - crashes. Actually, just closes the window.
TC16 - Prompts if I want to cancel the batch job
 
Aug 19, 2008
146
0
#10
I imagine other signals (than Ctrl-C) could trigger the prompt. When this is running at night, is there any hibernating or similar inactivity going on? Is the job a scheduled task ... or something that might trigger a logoff of the user owning the process?
The job is executed as a post action of another scheduled task. About the only thing that's running over night is backups. But it was popping up on demand yesterday. Looks like trying to CD to a non-existing folder was causing it - but only in v16, v11 reports the folder doesn't exist and continues the batch.
 
#11
The job is executed as a post action of another scheduled task. About the only thing that's running over night is backups. But it was popping up on demand yesterday. Looks like trying to CD to a non-existing folder was causing it - but only in v16, v11 reports the folder doesn't exist and continues the batch.
I don't think a missing folder can cause the "Cancel batch" prompt. I think that prompt can only come from a "signal" (notably, but not only, CTRL_C_EVENT). [Maybe Rex will chime in here.] If the batch file is running as a "post action of another scheduled task" (I'm not sure what that is) it might be getting the signal CTRL_LOGOFF_EVENT. That signal could evoke the "Cancel batch" prompt. You could check the Security event log to see what logons/logoffs happen when your tasks are run.
 
Aug 19, 2008
146
0
#14
Looks like it was a problem with jpstree.idx. My config is such that CD to a non-existent directory will cause it to search the index. That path in the code was what crashed 13 and caused the prompt in 16. Today I was having problems getting CDD to work and ended up re-building the .idx. Now CDD works again and when running my BTM, v16 (like v11) reports the non-existent directory when it encounters one instead of issuing the do I want to cancel prompt.