Results 1 to 13 of 13

Thread: Writing memory-resident program back to disc

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    4

    Writing memory-resident program back to disc

    I know this is probably an easy question for you gurus! but anyway:

    I have a program running on a machine. I want the program to write itself (as in whatever.exe) back onto the machine. What would be the best/easiest or quickest way to achieve this?

    Please help, I've looked through pages of examples and can't find anything on this.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    If I understand you correctly you want the program to copy itself.
    If that is correct you can simply use the FileCopy statement.
    Code:
        Dim sApp As String
        sApp = App.Path
        sApp = sApp & IIf(Right$(sApp, 1) <> "\", "\" & App.EXEName & ".exe", App.EXEName & ".exe")
        FileCopy sApp, "c:\MyApp.exe"
    Best regards

  3. #3
    chenko
    Guest
    Can you do that when the file is open?

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    4
    Urmm, does that AppPath mean it's copying the file from where it was run?


    Say the .exe file doesn't exist (physically) on the machine it's running on. It's been executed and now it's in memory. can it write itself back to the disc someplace?

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by chenko
    Can you do that when the file is open?
    Yes you can read and copy the file but you can't write to it.

    Originally posted by spiritdmp
    Urmm, does that AppPath mean it's copying the file from where it was run?

    Say the .exe file doesn't exist (physically) on the machine it's running on. It's been executed and now it's in memory. can it write itself back to the disc someplace?
    The EXE file must be somewhere otherwise it can't be executed in the first place, can it?
    It doesn't matter if it's started from a server as long as you are still connected to that server, or if your able to reconnect to it.

    Best regards

  6. #6

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    4
    Lets say for the sake of argument you dont have any access to a physical copy of the executable. (at all)

    Would I have to find the program's memory address/es and use them to create a file to save?

  7. #7
    chenko
    Guest
    oh i get it...

    he means the program is in the memory... and he wants the orignal file that it started from, maybe its deleted after running...oh what the heck am i talking about now, lol

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    I'm not sure, but I don't think this is possible because the program will not be stored in memory the same way as it's stored on disk.
    It will normally actually use more memory, for stacks and things like that.

  9. #9
    chenko
    Guest
    well some virii are run in the memory, but I think things like that are out of VB's hands.


    Whats your purpose for this spiritdmp?

  10. #10
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by chenko
    well some virii are run in the memory, but I think things like that are out of VB's hands.
    Yes but they will still need to be saved on disk otherwise they would dissapear when you turn the computer off.

  11. #11
    chenko
    Guest
    ...just like the code red virus which disappeared when the computer is restarted

  12. #12

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    4
    Im making a very small program that I can start as a process remotely on a users machine, or they start themselves by going to a certain page (or whatever) which then monitors stuff - like network usage, system performance etc and passes that info back to a main database. The program itself has to be totally transparent to the user (already sussed how to do that bit). I want the program to be self-maintaining so that it can replicate to a certain degree (like virii - as you mentioned).

  13. #13
    chenko
    Guest
    I think using VB to do this is a bit outa the way really.

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