How pass parameters to exe

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

How pass parameters to exe

Post by JosepM » Fri Jun 19, 2015 12:21 am

Hi,

I have a little utility that perfom an update to one database but I need to call it from the windows task manager. How can pass some parameter to the app? is posible?
I need pass a value or string.

Salut,
Josep M

zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm
Location: Greece

Re: How pass parameters to exe

Post by zaxos » Sat Jun 20, 2015 6:54 pm

Code: Select all

launch theParameter with "yourPath/YourApp.exe"
OR

Code: Select all

get shell("explorer"&&quote&"yourPath/YourApp.exe theParameter"&quote)
Knowledge is meant to be shared.

JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

Re: How pass parameters to exe

Post by JosepM » Mon Jul 20, 2015 8:21 pm

Hi,

But I need call from the windows task manager.
Any help about how call it from cmd window?

MaxV
Posts: 1576
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: How pass parameters to exe

Post by MaxV » Tue Jul 21, 2015 3:54 pm

zaxos is right, shell() function is what you need, for example:

Code: Select all

put shell("dir")
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

Re: How pass parameters to exe

Post by JosepM » Tue Jul 21, 2015 5:52 pm

Hi,

Nop. I need call the .exe outside Livecode, I want schelude a task from the Windows task manager and I can't use "put xXXX", isn't?

Klaus
Posts: 11823
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How pass parameters to exe

Post by Klaus » Tue Jul 21, 2015 6:36 pm

Hi Josep,

that depends on your database EXE! :D

Most of the time these command line tools have a build-in help that you can call in the DOS prompt like:
name_of_your_db.exe /?

Or maybe:
name_of_your_db.exe -h


Best

Klaus

JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

Re: How pass parameters to exe

Post by JosepM » Tue Jul 21, 2015 8:59 pm

Hallo Klaus,

Yes. But I don't know how pass the parameter to the application and how handle it from livecode.

I have a livecode an app that perform some actions when the user click on the buttons. I need execute the app with parameter to auto-execute the actions.

myapp.exe -auto

From livecode if I get the parameter "auto", the app must perform the actions and quit as unattended mode.

Salut,
Josep M

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7719
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How pass parameters to exe

Post by FourthWorld » Tue Jul 21, 2015 9:17 pm

You can obtain the arguments passed to a LiveCode app with the global variables $1, $2, etc. You can get the number of such arguments with $#.

In a future version this will be even easier:
http://quality.runrev.com/show_bug.cgi?id=12108
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

Re: How pass parameters to exe

Post by JosepM » Tue Jul 21, 2015 10:51 pm

Hi,

So from DOS command line myapp.exe myfirstparam mysecondparam

And from Livecode...

on preopenstack
global $1,$2
put $1 into tParamOne
put $2 into tParamTwo

... do something

end preopenstack

This way?

Salut,
Josep M

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7719
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How pass parameters to exe

Post by FourthWorld » Tue Jul 21, 2015 10:56 pm

Yep. And if you want the app to run without a UI, you can add -ui as the first of those arguments and the engine will boot faster with less RAM, bypassing all UI initialization, e.g.:

Code: Select all

myapp.exe -ui arg1 arg2
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

Re: How pass parameters to exe

Post by JosepM » Tue Jul 21, 2015 11:33 pm

Hi,

Nice :) Exist any other parameters? like -ui ?

The params are separated by comma or space from DOS command? or -param1 -param2 ?

On the Macosx terminal is the same?

Salut,
Josep M

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7719
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How pass parameters to exe

Post by FourthWorld » Tue Jul 21, 2015 11:36 pm

Args passed to an app are not normally separated by commas. I've corrected my example above to remove the errant comma that had been there.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

Re: How pass parameters to exe

Post by JosepM » Wed Jul 22, 2015 1:21 am

Thanks :)

Salut,
Josep M

JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

Re: How pass parameters to exe

Post by JosepM » Thu Jul 30, 2015 10:16 am

Hi,

Works perfect! but now I want exit the app when finish. I use the quit command but the app still reside on memory and don't auto-quit.
What I'm doing wrong?

On preopenstack I get the params.
On openstack if exist any param I execute the actions and quit the app.

I tryed the same from the preopenstack without success.

UPDATE: I tryed also lock messages and quit, but not success, the app remain on memory...

Salut,
Josep M

AxWald
Posts: 426
Joined: Thu Mar 06, 2014 2:57 pm

Re: How pass parameters to exe

Post by AxWald » Thu Jul 30, 2015 1:44 pm

Hi,
JosepM wrote:Works perfect! but now I want exit the app when finish. I use the quit command but the app still reside on memory and don't auto-quit.
Had similar problems with using -ui, the stack would not close properly

Solved it with calling the stack in VB with "vbhidden", but that's not always possible.
Other idea would be to check $# in preopenstack, and if > 1 (means there are cmd line arguments), set the visible of the stack to false.

Seems it has to do with visual actions in the stack, for instance:

Code: Select all

put $1 into field OneField
So that the engine tries to update the gfx of the field, but fails since it has no gfx stuff loaded ...
Not sure, maybe someone of the pros has more insight ;-)

Have fun!

PS: I find it useful to have a flag in stacks that have an auto-quit feature - I use such in the openstack script:

Code: Select all

if the shiftkey is down then put false into autorun else put true into autorun
Where autorun is a global that is checked before the "quit" cmd. Then start it with Shift pressed and it will stay alive, for better usability ;-)
Livecode programming until the cat hits the fan ...

Post Reply

Return to “Windows”