Before posting, and to avoid disappointment, please read the following:

  • This forum is not for 2BrightSparks to provide technical support. It's primarily for users to help other users. Do not expect 2BrightSparks to answer any question posted to this forum.
  • If you find a bug in any of our software, please submit a support ticket. It does not matter if you are using our freeware, a beta version or you haven't yet purchased the software. We want to know about any and all bugs so we can fix them as soon as possible. We usually need more information and details from you to reproduce bugs and that is better done via a support ticket and not this forum.

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

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

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

Post by NginUS »

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: 13
Joined: Mon Sep 06, 2010 3:20 am

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

Post by NginUS »

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

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

Post by NginUS »

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: 13
Joined: Mon Sep 06, 2010 3:20 am

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

Post by NginUS »

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: 13
Joined: Mon Sep 06, 2010 3:20 am

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

Post by NginUS »

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: 13
Joined: Mon Sep 06, 2010 3:20 am

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

Post by NginUS »

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