Page 1 of 1

'OnCanRunProfile' not working

Posted: Sat Jul 12, 2025 7:35 am
by PeterC
I have 2 profiles that I don't want to run at the same time. The profile names (taken from the 'Rename Profile' dialog box) are:
• p1 "[chn00] C:\(slctd,excl)--SamsungT7-L:\UserData" &
• p2 "[chn20] SamsungT7-L--Wombat (sleep)"

I have them in different 'Profile Groups' as shown in the below screenshot.
20250712 OnCanRunProfile.jpg
20250712 OnCanRunProfile.jpg (42.62 KiB) Viewed 12296 times
In Program Settings > Advanced > Global Pascal Script for All Profiies... I have the script:

Code: Select all

const p1='[chn00] C:\(slctd,excl)--SamsungT7-L:\UserData';
      p2='[chn20] SamsungT7-L--Wombat (sleep)';

function OnCanRunProfile(const ProfileName:UnicodeString; var PostponeBySeconds:Integer):Boolean;
begin
  if ProfileName=p1 then
     Result:=not ProfileRunning(p2)
  else
     if ProfileName=p2 then
       Result:=not ProfileRunning(p1)
     else
       Result:=true;
  if not Result then
     PostponeBySeconds:=60;
  end;
My problem is I'm still getting these 2 profiles running simulateously.

Re: 'OnCanRunProfile' not working

Posted: Sun Jul 13, 2025 10:38 pm
by tobias
Hello,
can you describe more precisely under which circumstances this happens? Does the scheduler start them? What's the schedule that the profiles have?

How frequently does it happen? Do you ever see the scheduler reporting "Not running job due to PascalScript"? Or does the PascalScript never prevent the second start?

It works fine here, the only situation I could imagine where it can happen is if the scheduler starts them almost at the same time, and the script might not work in that case.

Re: 'OnCanRunProfile' not working

Posted: Mon Jul 14, 2025 2:56 am
by PeterC
The scheduler starts p1 every 30 min at approx. 00:15/00:45 of the hour.

p2 is run as the third of 3 profiles that run in sequence started by the scheduler at 00:00 daily (I have them set up under 'Job' 'Execute after' with 'RUN PROFILE').

p2 takes anywhere from a few min to a few hours to run and I think the conflict happens every time p2 takes longer than 30 min. I never see the scheduler reporting "Not running job due to PascalScript".

Re: 'OnCanRunProfile' not working

Posted: Sat Jul 26, 2025 12:35 am
by tobias
OnCanRunProfile is not applied to chained profiles.

You would need to add a PascalScript to the chained profiles itself, for example:

Code: Select all

const p1='[chn00] C:\(slctd,excl)--SamsungT7-L:\UserData';
function OnProfileStart:Boolean;
begin
  Result:=not ProfileRunning(p1);
  end;

Re: 'OnCanRunProfile' not working

Posted: Sat Jul 26, 2025 5:55 am
by PeterC
Thanks for the reply.

Do I still need the Global Pascal Script for All Profiles?

Re: 'OnCanRunProfile' not working

Posted: Sun Aug 03, 2025 8:22 pm
by tobias
Hi,
you would only need the global PascalScript if both profiles have a schedule.