Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8709857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:28:31+00:00 2026-06-13T04:28:31+00:00

So i am trying to create a self replicating .exe in c++ using code::blocks

  • 0

So i am trying to create a self replicating .exe in c++ using code::blocks. I have written the code and on my local machine it works flawlessly. After loading it on a Windows 7 Virtual machine and 2 other PCs, i realized it does not work. It comes up with the error

“Can not copy file, access denied”

My PC probably has different permissions set i am assuming which is why it works on mine and not others. Here is the section of code:

ifstream check( "C:\\newfile.exe" );

if( !check.is_open() )
{
    char bufferf[MAX_PATH];
    GetModuleFileName( NULL, bufferf, MAX_PATH );
    std::stringstream str;

    str << "copy " << bufferf << " C:\\newfile.exe";
    system( str.str().c_str() );
    system( "start c:\\newfile.exe" );
    cout << __argv[0] << endl;
    return 1;
}
else
{
    return 0;

}

Remember i am very new to c++, long time java, php and c# developer but i figured it is time to learn a lower level language. If you have any suggestions on making this a more efficient function then please let me know.show any code you can since im not 100% familiar with all the libraries yet. long story short i want to copy the current exe to the cdrive, run that copied file and close the original. here is another way i tried

ifstream check( "C:\\newFile.exe" );

if( !check.is_open() )
{
    char bufferf[MAX_PATH];
    GetModuleFileName( NULL, bufferf, MAX_PATH );

    char * original_file = bufferf;
    char * new_file = ( char * )"c:\\newFile.exe";
    ( void ) CopyFile( ( LPCTSTR )original_file, ( LPCTSTR )new_file, FALSE );
    system( "start c:\\newFile.exe" );
    cout << __argv[0];
    return 1;
}
else
{
    return 0;
}

Still no success. but both work flawlessly on my development machine (from what i can see) i heard people say you can not copy running exe files in windows but that is not true, i feel it is a permissions issue but i may be wrong.

Any tips on self replication are welcome, i’m open to new methods.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:28:32+00:00Added an answer on June 13, 2026 at 4:28 am

    please know that, Windows Vista and Windows 7 have UAC enabled which doesn’t allow you to “write” to certain folders. You might have to run the program in Administrator mode or disable UAC altogether for your program to copy/create file from one location to the protected special folder.

    To request the user to allow a program to be run in administrative mode, you must define and link a manifest file to your application: This tells you how to do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a self referencing object using linqTOsql mapping. So far, I
I am trying to create a self-signed SSL certificate using OpenSSL (the version that
I am trying to create a self signed certificate on Windows machines. I want
I find my self lost while trying to create an actually pretty easy SQL
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Ok so I am trying create a login script, here I am using PHP5
Trying to create a black line in my view to separate text blocks but
I'm trying to create a self documenting python web service. My Situation: I've got
I am trying to create a menu with PySide. This is the code def
I'm trying create a gui using Tkinter that grabs a username and password and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.