Results 1 to 6 of 6

Thread: Allow user to embed data while passing exe around

  1. #1

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Allow user to embed data while passing exe around

    Don't know if this belongs in the C# forum or here, so feel free to move it if you guys feel it would better fit elsewhere.

    I have a C# winform app I built that is used for connecting to a game. What I want to do is allow an administrator of a server to download the application, set some stuff up in it like their server IP, port, updater URL, etc., and then distribute that to other players so they don't have to manually re-add that information.

    I could always add an app.config or a configuration file to the application, but I was hoping to somehow allow the admin to embed all the data so all the user ever receives is the single .exe.

    I could always build something that makes an installer for the user, but I was hoping to avoid that step.

    Does anyone have any suggestions or ideas?

    Thanks!

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: Allow user to embed data while passing exe around

    It will be interesting to see what others say, but I would suggest that the configuration file approach is the most common solution to problems like this. For one thing, if you have to make a change then you are changing a relatively tiny config file (text, JSON, XML, binary, or whatever) rather than needing to mess with the far more significant .exe file.
    My usual boring signature: Nothing

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Allow user to embed data while passing exe around

    Back in my pre-PC days we would patch an .exe with hardcoded values if we needed to.

    There must be a way to do that same thing safely.

    Probably have to be fixed length values...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Allow user to embed data while passing exe around

    Thanks for the replies guys. At this point I've decided to use NullSoft's NSIS. I just set some variables at the top of the script that they can modify and create their own installer.

    Not as robust as I wanted, but at least with this they don't need visual studio or a C# compiler to modify the codebase... just download the NSIS compiler, right click the script and voila.

    I'm still looking as NSIS has a 2GB limit, and will update the post if I find anything better.

    And of course if someone knows a better way, let me in on it

  5. #5
    PowerPoster SJWhiteley's Avatar
    Join Date
    Feb 2009
    Location
    South of the Mason-Dixon Line
    Posts
    2,256

    Re: Allow user to embed data while passing exe around

    Quote Originally Posted by kfcSmitty View Post
    Thanks for the replies guys. At this point I've decided to use NullSoft's NSIS. I just set some variables at the top of the script that they can modify and create their own installer.

    Not as robust as I wanted, but at least with this they don't need visual studio or a C# compiler to modify the codebase... just download the NSIS compiler, right click the script and voila.

    I'm still looking as NSIS has a 2GB limit, and will update the post if I find anything better.

    And of course if someone knows a better way, let me in on it
    You don't need an IDE to compile .NET apps. As ling as the .NET framework is installed, you have the .NET compiler. It is possible to create your own customized mini-IDE which will compile modules using the C# compiler. You would probably create the configuration file as a resource rather than messing with source code, and the app would just read configuration entries from the resource file.
    "Ok, my response to that is pending a Google search" - Bucky Katt.
    "There are two types of people in the world: Those who can extrapolate from incomplete data sets." - Unk.
    "Before you can 'think outside the box' you need to understand where the box is."

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Allow user to embed data while passing exe around

    Instead of using a legacy scripted setup you could just package into an MSI database.

    Then it should be fairly simple to write a small program to allow editing of config file values and replace the skeleton config file in the MSI database with the new edited one. Just hand out this new MSI database to users for installing.

    The only downside is it doesn't work with signed MSI files because you break the signature. This probably isn't an issue though.


    If you must use a scripted installer there ought to be some equivalent way of extracting then replacing an individual resource like this. That depends on how your 3rd party tool bundles the pieces and parts (CAB, ZIP, etc. formats usually).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width