command line parameters

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
SandyDoss
Junior Coder
Posts: 40
Joined: Wed Sep 07, 2016 12:47 am

command line parameters

Post by SandyDoss » Wed Apr 05, 2017 6:52 pm

Hello,

Is there a way to accept a value into a script by running a .exe with a parameter?
How do we check if the parameter is empty?

---
*edit* So, after posting, my search skills somehow evolved to a point where I can actually find what I'm looking for.

I believe the answer is yes, there is a way:

Run>full-path-scriptname.exe /variable=value

This makes the variable name available to the script with the value assigned.

Run>full-path-scriptname.exe /variable=

This makes the variable name available to the script with a value of 'nothing', or 'empty'

If I'm wrong, please let me know. Otherwise, thanks for allowing me to demonstrate my blonde factor :)

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

Re: command line parameters

Post by Marcus Tettmar » Fri Apr 07, 2017 8:53 am

To see if the variable exists just use the Assigned function:

Code: Select all

Assigned>VarName,VarExists
If>VarExists=FALSE
  Let>VarName=DefaultValue
Endif
So if you call your macro with:

exename.exe /VarName=fred

Then VarName is set to "fred"

But if you call it with:

exename.exe

Then VarName is set to "DefaultValue".

So there's no need to do /VarName=

But you can if you like! :-)
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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