Launching a script - SOLVED!

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Launching a script - SOLVED!

Post by mightycpa » Wed Mar 17, 2021 1:10 am

Hi,

A few of my scripts do what they need to do and then progress onto a subsequent script to perform the next step.

I want to use code like this at the end of my scripts, which is meant to accommodate running both scripts and compiled scripts. That way I don't have to change anything when I compile the final version.

Code: Select all

Label>MyExit
Include>%SCRIPT_DIR%\load_prog_ini.scp
If>%v_debug%=Y
  Ask>%SCRIPT_NAME% IS DONE. Do you want to run the next one?,v_continue
  If>%v_continue%=YES
      Ask>Examine variables?,v_examine
      If>v_examine=YES
        **BREAKPOINT**            
      Endif  // v_examine       
      //Dev and Test
      Run>%SYS_NATIVE%\%v_scp_next%
  Endif  // v_continue
Else
    //Production
    Run>%v_prog_next%  
Endif
Exit>
For the scripts,
1) Does the calling script finish, or does it stay running until the script it calls is finished? I'm trying to minimize the memory footprint, so I'd like for the calling script to close and the called script to take over. If this doesn't do the job,
2) How do I run the called script and close the calling script?
3) I got this when I tried to run it. Image
I'm sure this:

Code: Select all

Run>%SYS_NATIVE%\%v_scp_next%
isn't the right path. What should I use?

For the compiled scripts,
4) I'm operating under the assumption that if I set RP_WAIT=0, then I can run asynchronously, and the calling program will close while the called program keeps chugging along. Right?
5) if I prefix the compiled with %SYS_NATIVE%, I still have the wrong path. So what do I do about that?

Thanks in advance.
Last edited by mightycpa on Fri Mar 19, 2021 2:44 am, edited 1 time in total.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Launching a script

Post by mightycpa » Wed Mar 17, 2021 3:29 pm

this 64-bit problem is giving me some real heartburn:

Adding/using the following doesn't help, and I've added an image for slightly different errors:

1. Let>RP_WIN64PROCESS=1
Image
2. Run>%SYS_NATIVE%\%v_scp_next%
Image
3. Run>%SYS_NATIVE% msched.exe %SCRIPT_DIR%\%v_scp_next%
Image
4. I've changed my LocalSecurity Policy to elevate without prompt when programs are run (no effect)
5. I've changed msched.exe to always run as Administrator (no effect)
6. I've changed the compatibility setting to Windows 7 (no effect)

I'm out of ideas, and could really use some guidance here.
Image
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Launching a script

Post by mightycpa » Wed Mar 17, 2021 8:42 pm

If I switch over to Win 10 64-bit, can I avoid all this? Is it easier, or will I end up with the same issues?
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Re: Launching a script

Post by Bob Hansen » Wed Mar 17, 2021 11:07 pm

Hello again....

I just tried your script on my Wind 10. 64 bit.

As expected, I have a number of conditions I need to duplicate this. Again,can you provide some sample ini and scp files so I don't need to created them my self? I can easily change paths, but the files and the Include links will be too much work, and probably wrong anyway.

I am willing, you know that, but want to make sure we have the same testing. I know you have heard that before. Have you asked Dorian if he knows about a fix, before we do this? :oops:
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Launching a script

Post by mightycpa » Thu Mar 18, 2021 12:01 am

OK, here you go: https://anonymousfiles.io/YYosoVp8/

4 files in a zip file:
start.scp
middle.scp
end.scp
load_prog_ini.scp

What to do:
Create a folder C:\MS15\TEST_1 and put all 4 in it.
If you don't like that folder, and you want another one, then you have to change the MY_DIR line in start, middle and end. It's at or very close to the top.

How to run:
Launch start.scp. It will wait 5 seconds, then you'll see the dialog. Answer Y. The examine variables dialog will appear, it doesn't matter how you answer that. Just say No. If start runs as intended, then middle will run next. Same procedure, and then end will run. Same procedure, back to start. It's circular and will run forever. The 5 second wait in each will allow you to break out.

These scripts don't work for me. When I answer Y in start, the next thing I get is the dreaded Image (no, that's not from these files, but I didn't want to upload another nearly identical image)

Thanks Bob.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

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

Re: Launching a script

Post by Dorian (MJT support) » Thu Mar 18, 2021 11:33 am

Forgive me if I am missing a point somewhere, but why not use Macro for running an scp file, and Run for running an exe?

I compiled middle.exe. Then these all ran "middle" successfully for me on 64 bit Win 10.

Code: Select all

macro>c:\MS15\TEST_1\middle.scp
include>c:\MS15\TEST_1\middle.scp
run>c:\MS15\TEST_1\middle.exe
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Launching a script

Post by Marcus Tettmar » Thu Mar 18, 2021 12:15 pm

You cannot 'RUN' a .scp file directly.

This has nothing to do with 64 bit. You just can't run .scp files - they are not executable.

You can pass them to macro scheduler or use ExecuteFile (which runs the default command associated with the file extension):

run>c:\....\msched.exe "c:\path\scriptfile.scp"

But you cannot just put a .scp file in a Run command. That would be like typing the path of the .scp file in your DOS command prompt. It won't know what to do.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Launching a script

Post by mightycpa » Thu Mar 18, 2021 3:45 pm

Marcus,

Please take a look at my second post, specifically item #3. I think I tried exactly as you suggested.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Launching a script

Post by mightycpa » Thu Mar 18, 2021 3:51 pm

Hi Dorian,

For the executables, I'm hoping I don't have a problem, but you know, I haven't tried compiling them and seeing if compiled files act the same way, so I'll do that and let you know.

As for the uncompiled scp's, I am trying to minimize the memory footprint. These small files are just illustrative of the real thing. The purpose of this end of script block is to have uncompiled scripts that can run in the same way the compiled ones will run, ie, one calling the next when finished. In addition, this block allows me to see if there are any problems with my script before it calls the next one. I can pause execution of each script, examine its variables and see if it did everything it was supposed to do.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Launching a script

Post by Grovkillen » Thu Mar 18, 2021 4:04 pm

In my experience a compiled script have a fairly small memory footprint.
Let>ME=%Script%

Running: 15.0.27
version history

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

Re: Launching a script

Post by Dorian (MJT support) » Thu Mar 18, 2021 4:06 pm

mightycpa wrote:
Thu Mar 18, 2021 3:45 pm
Marcus,

Please take a look at my second post, specifically item #3. I think I tried exactly as you suggested.
Both of these ran from within Macro Scheduler

Code: Select all

run>msched.exe "c:\MS15\TEST_1\middle.scp"
run>c:\Program Files (x86)\Macro Scheduler 15\msched.exe "c:\MS15\TEST_1\middle.scp"
Yes, we have a Custom Scripting Service. Message me or go here

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Launching a script

Post by mightycpa » Thu Mar 18, 2021 4:13 pm

Good. I would expect them to run.

On my system, they don't. I'm using Windows Server 2008. What OS are you running?
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Launching a script

Post by mightycpa » Thu Mar 18, 2021 4:17 pm

Hi Grovkillen, yeah, the memory footprint thing is for the uncompiled scripts. The less memory I put on the box, the less I have to pay each month. I'd love to be able to go as low as the bare minimum stated requirements for MS, 1024MB.

The actual scripts I'm trying to do this with a fairly lengthy. If they all get loaded and essentially become one script, well, that's what I'm trying to avoid.

I imagine that the Run>msched.exe script.scp allows the calling script to finish and end, accomplishing my goal. I just want to see both the compiled and uncompiled calls work on my machine. It would be nice if I didn't have to include Windows 10 in the mix, and could run all of this on Windows server.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

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

Re: Launching a script

Post by Dorian (MJT support) » Thu Mar 18, 2021 5:33 pm

mightycpa wrote:
Thu Mar 18, 2021 4:13 pm
Good. I would expect them to run.

On my system, they don't. I'm using Windows Server 2008. What OS are you running?
Windows 10 64 bit.
Yes, we have a Custom Scripting Service. Message me or go here

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Launching a script

Post by mightycpa » Thu Mar 18, 2021 8:26 pm

Thanks all, with your help, I've been able to get rid of the conflicts I experienced earlier. I also found a couple issues with my earlier scripts, so I have corrected and improved them. Progress! New scripts:

launch

Code: Select all

Let>v_trash=
Include>%SCRIPT_DIR%\load_prog_ini.scp
Wait>2
Run>%COMMAND_LINE% "%v_scp_first"%

start

Code: Select all

// COMPILE_OPTS|C:\MS15\TEST_1\start.exe||CONSOLE=0|INCLUDES=1||RUNTIMES=1|BMPS=1
//put the files wherever you want
Let>v_debug=Y
//any kind of code you want in here

Let>a=1
Wait>5

Label>MyExit
Include>%SCRIPT_DIR%\load_prog_ini.scp
Let>RP_WAIT=0
If>%v_debug%=Y
  Ask>%SCRIPT_NAME% IS DONE. Do you want to run the next one?,v_continue
  If>%v_continue%=YES
      Ask>Examine variables?,v_examine
      If>v_examine=YES

**BREAKPOINT**
      Endif  // v_examine
      //Dev and Test
      MessageModal>%SCRIPT_DIR%\%SCRIPT_NAME% will run %v_scp_next_1%
      Run>%COMMAND_LINE% "%v_scp_next_1%"
      Wait>2
      Exit>
  Else
      MessageModal>Script will now end
      Exit>
  Endif  // v_continue
Else
    //Production
    //Run>%v_prog_next_1%
    MessageModal>one thing at a time
    Exit>
Endif
Exit>

middle

Code: Select all

// COMPILE_OPTS|C:\MS15\TEST_1\middle.exe||CONSOLE=0|INCLUDES=1||RUNTIMES=1|BMPS=1
Let>v_debug=Y
//any kind of code you want in here

Let>b=2
Wait>5

Label>MyExit
Let>RP_WAIT=0
Include>%SCRIPT_DIR%\load_prog_ini.scp
If>%v_debug%=Y
  Ask>%SCRIPT_NAME% IS DONE. Do you want to run the next one?,v_continue
  If>%v_continue%=YES
      Ask>Examine variables?,v_examine
      If>v_examine=YES
**BREAKPOINT**
      Endif  // v_examine
      //Dev and Test
      MessageModal>%SCRIPT_DIR%\%SCRIPT_NAME% will run %v_scp_next_2%
      Run>%COMMAND_LINE% "%v_scp_next_2%"
      Wait>2
      Exit>
  Else
      MessageModal>Script will now end
      Exit>
  Endif  // v_continue
Else
    //Production
    //Run>%v_prog_next_2%
    MessageModal>one thing at a time
    Exit>
Endif
Exit>

end

Code: Select all

// COMPILE_OPTS|C:\MS15\TEST_1\end.exe||CONSOLE=0|INCLUDES=1||RUNTIMES=1|BMPS=1
Let>v_debug=Y
//any kind of code you want in here

Let>c=3
Wait>5

Label>MyExit
Let>RP_WAIT=0
Include>%SCRIPT_DIR%\load_prog_ini.scp
If>%v_debug%=Y
  Ask>%SCRIPT_NAME% IS DONE. Do you want to run the next one?,v_continue
  If>%v_continue%=YES
      Ask>Examine variables?,v_examine
      If>v_examine=YES
**BREAKPOINT**
      Endif  // v_examine
      //Dev and Test
      MessageModal>%SCRIPT_DIR%\%SCRIPT_NAME% will run %v_scp_next_3%
      Run>%COMMAND_LINE% "%v_scp_next_3%"
      Wait>2
      Exit>
  Else
      MessageModal>Script will now end
      Exit>
  Endif  // v_continue
Else
    //Production
    //Run>%v_prog_next_3%
    MessageModal>one thing at a time
    Exit>
Endif
Exit>
load_prog_ini

Code: Select all

//scripts
Let>v_scp_next_1=%SCRIPT_DIR%\middle.scp
Let>v_scp_next_2=%SCRIPT_DIR%\end.scp
Let>v_scp_next_3=%SCRIPT_DIR%\start.scp
Let>v_scp_first=%v_scp_next_3%

//compiled
Let>v_prog_next_1=%SCRIPT_DIR%\middle.exe
Let>v_prog_next_2=%SCRIPT_DIR%\end.exe
Let>v_prog_next_3=%SCRIPT_DIR%\start.exe
Maybe there's some uncertainty about what I want to do. Here is some clarity:
Image

Here are the changes from the original:
I added the launch script because the first instance of msched.exe stays running throughout the session.
I added an RP_WAIT=0 so that the calling program doesn't wait for the called program to terminate.
I added a Wait>2 after executing the call to allow time for the called script to launch.
I added an Exit> so that the calling script will quit after the wait. We don't want an ever-increasing number
of msched.exe's in memory.
I added richer descriptions to the message boxes so that we know what the script should do.

I'm almost there, but I've run into an unexpected snag. You can see it here. Use pause to examine in detail:
Image

I'm going to add the compiled scripts next, see what happens. But the main purpose for doing this is to run the uncompiled scripts, for development, debugging and testing. Also, this is a proof of concept. The end goal is to incorporate this approach into several large scripts that actually do something.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

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