.bat in 'Programs - After', but only if [Profile Name] not running

For technical support visit http://support.2brightsparks.com/
Post Reply
NginUS
Enthusiastic
Enthusiastic
Posts: 15
Joined: Mon Sep 06, 2010 3:20 am

.bat in 'Programs - After', but only if [Profile Name] not running

Post by NginUS » Thu Nov 15, 2018 6:40 pm

I have a batch file that I'd like to run that shuts down the computer once the profile is complete.

Problem is, there's 2 profiles scheduled, & if one's still going when the other wants to shut down, it won't finish.

One's weekly & the other's monthly. The weekly one typically finishes within 2 days, while the monthly one maybe a week. It's likely one day they'll collide if I set this script.

Ideas?

TIA

NginUS
Enthusiastic
Enthusiastic
Posts: 15
Joined: Mon Sep 06, 2010 3:20 am

Re: .bat in 'Programs - After', but only if [Profile Name] not running

Post by NginUS » Sun Nov 25, 2018 8:10 pm

bump

NginUS
Enthusiastic
Enthusiastic
Posts: 15
Joined: Mon Sep 06, 2010 3:20 am

Re: .bat in 'Programs - After', but only if [Profile Name] not running

Post by NginUS » Sat Dec 01, 2018 2:06 am

After looking elsewhere for answers on this, we now have the following as a potential solution:

.bat 1:

Code: Select all

echo job 1 > c:\temp\job1.lock
syncbackpro /dojob:1
del c:\temp\job1.lock
if not exist c:\temp\job2.lock shutdown /s /f /t 0
.bat 2:

Code: Select all

echo job 2 > c:\temp\job2.lock
syncbackpro /dojob:2
del c:\temp\job2.lock
if not exist c:\temp\job1.lock shutdown /s /f /t 0
However I'm not entirely clear as to how exactly to implement it. If I would be better off using this as the scheduled task script that calls SBP from it? Or maybe parts of it should be run from within each SBP profile using its 'Run this before' & 'Run this after' functions?

Is anyone here able to make better sense out of this?

TIA...

NginUS
Enthusiastic
Enthusiastic
Posts: 15
Joined: Mon Sep 06, 2010 3:20 am

Re: .bat in 'Programs - After', but only if [Profile Name] not running

Post by NginUS » Sun Dec 02, 2018 12:08 pm

The following is what I've come up with initially. I have yet to test any of it, will check back & post my findings after doing so.

SBP Job 1's Profile settings:
Run Before:

Code: Select all

touch C:\Users\Username\Locks\JobI.lock
Run After:

Code: Select all

del C:\Users\Username\Locks\JobI.lock
if not exist C:\Users\Username\Locks\JobII.lock shutdown /s /f /t 0
SBP Job 2's Profile settings:
Run Before:

Code: Select all

touch C:\Users\Username\Locks\JobII.lock
Run After:

Code: Select all

del C:\Users\Username\Locks\JobII.lock
if not exist C:\Users\Username\Locks\JobI.lock shutdown /s /f /t 0

NginUS
Enthusiastic
Enthusiastic
Posts: 15
Joined: Mon Sep 06, 2010 3:20 am

Re: .bat in 'Programs - After', but only if [Profile Name] not running

Post by NginUS » Tue Jan 01, 2019 9:41 pm

Here to report that the above solution does indeed work as intended.

During a collision the first job to complete did not shut down & after the second completed it did.

Marking solved.

Just to be clear, Windows doesn't include a 'touch' command by default. I'm using 'touch.exe' from the following project on Sourceforge:
https://sourceforge.net/projects/touchforwindows/

NginUS
Enthusiastic
Enthusiastic
Posts: 15
Joined: Mon Sep 06, 2010 3:20 am

Re: .bat in 'Programs - After', but only if [Profile Name] not running

Post by NginUS » Tue Jan 01, 2019 9:42 pm

NginUS wrote:
Tue Jan 01, 2019 9:41 pm
Marking solved.
Apparently that's not allowed here. Oh, well.

Post Reply