1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Getting Executable Directory

Discussion in 'Programming' started by NoFontNL, Nov 10, 2019.

  1. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    305
    Is there a way to get the location of the executable. Let's say I export my game to C:\Users\Nofontnl\Desktop\Game\
    and when I run the game, how would I get above location? working_directory and program_directory don't return this path. Is there an extension? I've searched and downloaded some extensions, but there is no documentation, or I can't find the right function in the extension.

    Help would be appreciated. Thanks in advance.
     
  2. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,661
  3. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    305
    yes, I'm testing it when I compiled my game. Any suggestions?
     
  4. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    2,273
    I think its a bug, there was another thread about this recently. program_directory when used for writing files seems to incorrectly return the %localappdata% folder

    What folder is program_directory giving you?
     
  5. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    305
    this is what I get from show_message(program_directory)
    (Compiled game)
    upload_2019-11-10_14-11-45.png
     
  6. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,661
    What are you trying to do, copy files using that path?
    There are currently some issues with that which can be seen in this thread, but if you output program_directory to the console or the screen then it should report the correct directory that the compiled in being run is in - at least it does for me (it just doesn't work when copying files to it.)

    What version of GMS are you using?
     
  7. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,712
    This is what you get when using the single executable export. Don't use it and this will work as expected.
     
    rIKmAN likes this.
  8. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    305
    Is there a way to get the path with an extension? I'm trying to download files to the executable location.
     
  9. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,712
    I see no need to use an extension here when you're already using the correct function, but, at least from what I can tell, the wrong export. Until you've verified whether changing that will resolve this, there's no merit to offering further advice.
     
  10. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    305
    I am using the single executable export because of convenience. Changing the export type resolves this, but I wanted to know if there is a workaround, take for example an extension.
     
  11. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,661
    One of the extensions made by @Samuel Venable might do this, hopefully he can confirm and let you know which one when he sees this.
     
    Samuel Venable likes this.
  12. Samuel Venable

    Samuel Venable Time Killer

    Joined:
    Sep 13, 2016
    Posts:
    1,291
    Although if you are using the single exe export, it sounds like you are using GMS 1.4. My extension can't get the single exe's program path, because that is actually a parent process of the actual game being executed. If you export your game as a zip or installer, this extension should work for you: https://marketplace.yoyogames.com/assets/5510/file-manager
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice