1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

program cannot copy itself?

Discussion in 'Software Development' started by xenogen, Oct 3, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. xenogen

    xenogen Thread Starter

    Joined:
    Jan 12, 2008
    Messages:
    50
    i know this sounds like virus but its really not. i had a bit of an issue with file associations and a moving executable and figured the best way to fix it was have the program copy itself to its own resources directory when it runs (if it isn't already there) and ran into a problem. Program wont copy itself. could someone show me a way around this, or another way to do file associations when the executable is not always in the same place? btw i am using VB .NET
     
  2. jdean

    jdean

    Joined:
    Jan 20, 2002
    Messages:
    433
    Why isn't the executable always in the same place?
     
  3. xenogen

    xenogen Thread Starter

    Joined:
    Jan 12, 2008
    Messages:
    50
    in short, its standalone, sort of.
     
  4. jdean

    jdean

    Joined:
    Jan 20, 2002
    Messages:
    433
    well, if it's not a virus, then it sounds like some kind of spyware.
    this is really not appropriate for TechGuy.org
     
  5. xenogen

    xenogen Thread Starter

    Joined:
    Jan 12, 2008
    Messages:
    50
    the program is not a virus or spyware or malicious in any way. the reason i want it to copy itself is that i want the executable to be moveable, so standalone, but i also want file associations to work, and as far as i know file associations require a fixed executable path, so, i want to add in that the program checks for the existence of My documents\Pyroguide\Pyroguide.exe (pyroguide is the name of the program) and if it isn't there, creates it, and the file association is linked to that executable, so that if its run from an associated file, it will run that copy of the program, but it can still be run from the executable you move.

    pfft retarded subject..
     
  6. jdean

    jdean

    Joined:
    Jan 20, 2002
    Messages:
    433
    If you are trying to make the app portable, you might want to check out PortableApps.com or Google for "portable apps". There is an active community of people trying to create applications that can work from any path.

    I don't think that there is a portable way to do file associations, at least not anything that's standard. You can certainly create your own launcher that handles portable associations (see for example xyplorer, an advanced Explorer replacement that has a model for portable file associations).
     
  7. xenogen

    xenogen Thread Starter

    Joined:
    Jan 12, 2008
    Messages:
    50
    well yer, but that doesnt really answer my question
     
  8. Scott786

    Scott786

    Joined:
    Jul 9, 2008
    Messages:
    44
    If what your are trying to do is move the program from one location to a default location then the best thing to do is use the shell function.
    Code:
    Shell("cmd /c copy currentfilelocation defaultfilelocation",AppWinStyle.Hide)
    
    To get the current file location you can use the property Environment.CurrentDirectory. This will only give the folders so you have to add "\program.exe" to the string you are using.
     
  9. lotuseclat79

    lotuseclat79

    Joined:
    Sep 12, 2003
    Messages:
    20,583
    Hi xenogen,

    Please answer a question or two.

    An executable program usually resides on hard drive disk and is loaded into memory for execution. All programs when loaded into memory are loaded for execution to a particular place in memory to execute from.

    1) Are you talking about moving the executable file on disk to another location on disk prior to loading and executing it:

    In the first case, you would simply need to know the file's location in the file system by virtue of its absolute path name, and then just invoke the interfaces to open a new file by the same name in another path, or give it another name in the same file directory it resides.

    2) or, are you talking about making the executable position independent in memory and moving its location to another available memory location during execution dynamically?

    -- Tom
     
  10. JimmySeal

    JimmySeal

    Joined:
    Sep 25, 2007
    Messages:
    290
    Why not just make a proper installer for the program, that allows the user to choose the installation directory and sets up the associations? What you are describing is a hack.
     
  11. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/755752

  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