How to Compile Includes from the command line?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
robsmith
Newbie
Posts: 17
Joined: Mon Oct 30, 2023 2:12 pm
Location: USA

How to Compile Includes from the command line?

Post by robsmith » Thu Apr 18, 2024 7:56 pm

I intend to compile multiple scp files in a custom deployment script, instead of using the Macro Scheduler Pro Editor to compile each scp individually.
These scp files all reference the same set of Included subroutines.

Is there a parameter or other means to 'Compile Includes' from the command line? I could not find anything in documentation.

Perhaps this is not available functionality, and it is necessary to script my own concatenation of the subroutines before compiling the scp via the command line?

When I compile the scp with msrt.exe from the command line, the exe output does not contain the subroutines referenced via Include> statements.

I am using MS Pro 15.0.24 on Windows Server 2016, not making a console app, no nested includes or any variables in the Include>paths.

Here is an example, should this work?

scp file to compile:

Code: Select all

// COMPILE_OPTS|C:\testdir\testapp.exe||CONSOLE=0|INCLUDES=1||RUNTIMES=1|BMPS=1
Include>C:\testdir\Shared\subroutine1.scp
GoSub>subroutine1
MDL>Exit
Content of C:\testdir\Shared\subroutine1.scp:

Code: Select all

SRT>subroutine1
  MDL>subroutine1
END>subroutine1
Test 1: Compile Includes with Editor works as expected.
Compile testapp.exe from the Editor.
Rename C:\testdir\Shared to C:\testdir\Shared_ to verify the subroutine was compiled, and not referenced at runtime by the exe.
Run testapp.exe, the modal message 'subroutine1' appears, confirming the subroutine executed.

Test 2: Subroutine is missing when compiled from command line.
Rename C:\testdir\Shared_ back to C:\testdir\Shared (so the path is valid).
Confirm the first line of the scp contains 'INCLUDES=1'.
Compile testapp.exe from the command line.
Rename C:\testdir\Shared to C:\testdir\Shared_ (to ensure the subroutine scp isnt referenced at runtime).
Run testapp.exe, an error message appears, indicating the subroutine is missing.

Code: Select all

>"C:\Program Files (x86)\Macro Scheduler 15 Pro\msrt.exe" -COMPILE "C:\testdir\testapp.scp" "C:\testdir\testapp.exe"

I scoured the forums, manual, and tried a few things:

-Use the Windows Task Scheduler -> Details tab to inspect the command line arguments for the msrt.exe process that is launched when I compile the exe via the Editor. This revealed the Editor is building a temp file with the combined content of testapp.scp and subroutine1.scp in the C:\Users\username\AppData\Local\Temp\ folder, then compiling the temp file.

-Verified the // COMPILE_OPTS on line 1 contains the expected content. I concluded this is likely used only by the Editor, not by msrt.exe.

-Ran msrt.exe via command line with -help, help, /?, ?, and various other parameters but found no hints here.

If there is a smarter way to update several projects at once, I would love to have your suggestions!

Thank you,

Rob
Last edited by robsmith on Wed Apr 24, 2024 7:47 pm, edited 4 times in total.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1386
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: How to Compile Includes from the command line?

Post by Dorian (MJT support) » Fri Apr 19, 2024 1:23 pm

I've been testing possibilities quite extensively and it appears the sole cause is the path to msrt.exe

C:\Program Files (x86)\Macro Scheduler 15\msrt.exe
As opposed to :
C:\Program Files (x86)\Macro Scheduler 15 Pro\msrt.exe

I was able to successfully compile a script containing an include both with (my local paths) :

Command Line :

Code: Select all

"C:\Program Files (x86)\Macro Scheduler 15\msrt.exe" -COMPILE "C:\Users\zzzz\OneDrive\Documents\Macro Scheduler 15 Shared\comp.scp" "C:\Users\zzzz\OneDrive\can\test77.exe"
And from Macro Scheduler:

Code: Select all

runprogram>"C:\Program Files (x86)\Macro Scheduler 15\msrt.exe" -COMPILE "C:\Users\zzzz\OneDrive\Documents\Macro Scheduler 15 Shared\comp.scp" "C:\Users\zzzz\OneDrive\can\test212.exe"
Yes, we have a Custom Scripting Service. Message me or go here

robsmith
Newbie
Posts: 17
Joined: Mon Oct 30, 2023 2:12 pm
Location: USA

Re: How to Compile Includes from the command line?

Post by robsmith » Fri Apr 19, 2024 4:38 pm

I tested this on 3 different computers with Windows 10, I am still seeing the same problem:

After moving the Included scp files to a different path after compiling, the exe encounters the error 'Subroutine/Label subroutine1 Not Found!' when it tries to execute the subroutine.

This only happens when I compile using msrt.exe directly. When I compile from the Editor, the includes are compiled.

My windows installations are over a year old, so I installed the newest Virtualbox from Oracle, downloaded newest windows 10 ISO from Microsoft, created a VM, installed new windows OS with all defaults, and installed Macro Scheduler Pro 15.0.24 without changing any defaults and using my license key.

I recreated the same test scp files described in the first post, using the exact path to msrt.exe and command syntax recommended, yet it does not compile with the includes in this freshly prepared test environment--the Includes are only compiled from the Editor.

I have double checked everything and if I am doing something wrong, I cannot determine what it is :-(
It appears the 'Compile Includes' logic is part of the Editor and not msrt.exe.

As a workaround, I used ReadFile and Regex to find the Include> lines in my scp and concatenate the subroutines before compiling, but this causes system variables to be resolved when I write the results using WriteLn.

If 'Compile Includes' isn't intended to work with msrt.exe from the command line, I will use an external script, likely batch or PowerShell, to find the Include> lines in my scp file, then concatenate the contents of the Include files into the scp, then compile. This will emulate the steps taken by the editor. I am happy to do it this way if everything is working according to design.
Last edited by robsmith on Wed Apr 24, 2024 8:07 pm, edited 6 times in total.

robsmith
Newbie
Posts: 17
Joined: Mon Oct 30, 2023 2:12 pm
Location: USA

Re: How to Compile Includes from the command line?

Post by robsmith » Tue Apr 23, 2024 9:17 pm

Does msrt.exe read the first line of the scp to determine whether it should compile includes?

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1386
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: How to Compile Includes from the command line?

Post by Dorian (MJT support) » Tue Apr 23, 2024 9:47 pm

In all honesty I wasn't too sure, but yes, it certainly seems to.

If I compile an exe from within the editor and INCLUDES=1 is in line 1, the "compile includes" checkbox will be automatically selected. If I remove INCLUDES=1, it won't be. I can also control whether it will be by pasting line 1 into a completely fresh script.
Yes, we have a Custom Scripting Service. Message me or go here

robsmith
Newbie
Posts: 17
Joined: Mon Oct 30, 2023 2:12 pm
Location: USA

Re: How to Compile Includes from the command line?

Post by robsmith » Wed Apr 24, 2024 4:53 pm

When I compile from the command line--not via the Editor--it looks like the INCLUDES=1 logic is ignored.

From this, I infer that I cannot 'Compile Includes' without the Editor.
Is this accurate?

I am trying to determine if msrt.exe will 'Compile Includes', or if I must concatenate the included scripts on my own, before compiling 'from the command line'.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1386
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: How to Compile Includes from the command line?

Post by Dorian (MJT support) » Wed Apr 24, 2024 6:36 pm

Right, I have more info for you, and have found out why this was working for me without issue. My include filepath was hardcoded.

You should be able to compile an include from the command line if the include in your script contains a hard-coded path to the scp file :

Good:

Code: Select all

Include>C:\Users\zzzz\OneDrive\Documents\Macro Scheduler 15 Shared\sub1.scp
Bad:

Code: Select all

Include>%script_dir%\sub1.scp
Yes, we have a Custom Scripting Service. Message me or go here

robsmith
Newbie
Posts: 17
Joined: Mon Oct 30, 2023 2:12 pm
Location: USA

Re: How to Compile Includes from the command line?

Post by robsmith » Wed Apr 24, 2024 7:36 pm

In my first post in this topic, my example Include contains a hard-coded path.
I tried Includes both ways: hardcoded and based on SCRIPT_DIR and neither includes the subroutine content when I compile from the command line.

I promise I read through every post related to compiling and msrt that I could find before I asked :-)

Are you sure you are able to compile an scp from the command line and that Included subroutines still execute, after you remove the referenced scp file? I hope my example in the first post is fully copy/past-able to check.

I also reran the test in C:\Users\myusername\Documents\Macro Scheduler 15\testdir\ to rule out any disk related permissions.

Thank you very much for the responses :-)

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1386
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: How to Compile Includes from the command line?

Post by Dorian (MJT support) » Wed Apr 24, 2024 9:49 pm

robsmith wrote:
Wed Apr 24, 2024 7:36 pm
Are you sure you are able to compile an scp from the command line and that Included subroutines still execute, after you remove the referenced scp file? I hope my example in the first post is fully copy/past-able to check.
Aaah, I see what you mean now and am able to replicate. If I compile this from the command line, it initially works perfectly.

Code: Select all

Include>C:\Users\zzzz\OneDrive\Documents\Macro Scheduler 15 Shared\sub1.scp
But if I then rename sub1.scp to sub1a.scp, meaning sub1.scp no longer exists, and run the exe again, I get the subroutine not found error. Rename it back to sub1.scp and the exe works again.

Right, I'll see what I can find out.
Yes, we have a Custom Scripting Service. Message me or go here

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts