Can a MS .exe file get its own filename?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
utz
Newbie
Posts: 18
Joined: Sat Aug 11, 2007 8:33 pm

Can a MS .exe file get its own filename?

Post by utz » Tue May 05, 2009 7:15 pm

Hello again,

I'm running MS 11.1.08a and I have a question that I can't find documented anywhere. Sorry if this is a repeated question.

Is it possible for a compiled macro to get its own filename without knowing its location? Let's say I have an .exe compiled from MS named "hello.exe". Can the file, when run, get "hello" into a variable in some way?

Thanks, if you can help!

Utz

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 May 05, 2009 7:40 pm

Yes, parse SCRIPT_FILE which contains the full path to the script or exe. E.g. compile this code and run it:

Code: Select all

Separate>SCRIPT_FILE,\,parts
Let>fname=parts_%parts_count%
Separate>fname,.,parts
Let>fname=parts_1
MessageModal>fname
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

utz
Newbie
Posts: 18
Joined: Sat Aug 11, 2007 8:33 pm

Post by utz » Tue May 05, 2009 8:09 pm

Wow, that's perfect. Thank you so much! :)

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