Return Codes from Script .exe's?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
bladerun
Newbie
Posts: 7
Joined: Mon Dec 13, 2004 7:54 pm

Return Codes from Script .exe's?

Post by bladerun » Mon Dec 13, 2004 7:59 pm

I've got Macro Scheduler Pro to do everything I need so far, but I can't seem to find anything about Return Codes. Is it possible to send return codes from the compiled scripts? If not, I've got a work around - but RC's would be ideal for my project.

Thanks!

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

Post by Bob Hansen » Mon Dec 13, 2004 8:42 pm

By the term "return code", do you mean just pressing ENTER?

Try "PRESS ENTER"
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Guest

Post by Guest » Mon Dec 13, 2004 8:51 pm

Actually, I just mean sending a return code back from the script executable to indicate a condition within the script (success or failure, for example), sometimes called an exit code.

Example:

If (a=b)
return 0 (returns a zero to the calling program)
else
return 1 (returns a one to the calling program)

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

Post by Bob Hansen » Tue Dec 14, 2004 12:21 am

Run Program returns a variable RP_RESULT. You can check that value in your IF decision. From HELP on Run Program>:

By default a message is displayed if this command encounters an error when running the specified program. Error messages from this command can be suppressed by setting RP_DISPLAYERROR to 0.

The result of the Run Program command is stored in the variable RP_RESULT. A value greater than 31 indicates success. The following values represent errors :

0 - The system was out of memory, or the executable file was corrupt, or relocations were invalid.
2 - The file was not found.
3 - The path was not found.
5 - An attempt was made to dynamically link to a task, or there was a sharing or network protection error.
6 - The library required separate data segments for each task.
10 - The Windows version was incorrect.
11 - The executable file was invalid. It was either not a Windows-based application or there was an error in the .EXE image.
12 - The application was designed for OS/2.
13 - The application was designed for MS-DOS 4.0.
14 - The type of executable file was unknown.
15 - An attempt was made to load a real-mode application (developed for an earlier version of Windows).
16 - An attempt was made to load a second instance of an executable file containing multiple data segments that were not marked "read-only."
17 - Attempt in large-frame EMS mode to load a second instance of an application that links to certain non-shareable DLLs already in use.
18 - Attempt in real mode to load an application marked for protected mode only.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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

Post by Marcus Tettmar » Tue Dec 14, 2004 12:30 am

If you want to pass back your own data one way is to use environment variables. See the following commands:

SetEnvVar
GetEnvVar

The compiled macro could set an environment variable with SetEnvVar which will then be available to the calling process.

Macros can also set the MACRO_RESULT variable but this is only relevent for macros called by other macros. I suggest environment variables where you are calling scripts from other applications.

Other methods include INI files, setting registry keys and writing to text files.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

bladerun
Newbie
Posts: 7
Joined: Mon Dec 13, 2004 7:54 pm

Post by bladerun » Tue Dec 14, 2004 3:58 pm

Thanks Bob and Marcus, I appreciate the input!

I think I'll take Marcus's suggestion and write return code info to a .txt file or .ini file as a simple workaround.

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