I am trying to make my program more easy to use and not have computer illiterate people struggle to install my program. My question is can a C++ program install ITSELF into another directory upon execution.
I want the program to run, but I also want it to make a backup copy of the same program in a certain directory.

Thanks a lot guys. If you guys want me to post my soure code of my current program I will, but I think this is a self explanatory question and doesn't relate to the context of the sour code.

Thanks a lot for taking the effort to respond.

Recommended Answers

All 3 Replies

This sounds somewhat suspicious (very useful for a malicious program) but I could be wrong...

I believe you could have the program open a file in the target directory, named as you wish the backup to be called. If the file exists, nothing's left to do. Otherwise you'd have to know where the original was, and copy the file to your target file. I think that would work fine, but I don't know if your OS will lock the original executable on the hard drive (doubtful, 'specially if you're just reading it).

I want the program to run, but I also want it to make a backup copy of the same program in a certain directory.

Be kind to the computer illiterate people and keep to conventions. :) A better method is to give people an installer that installs the program and then runs it after the installation is done. You can also put a shortcut in the same directory as the installer, or on the desktop.

commented: I agree (iamthwee) +5
Member Avatar for iamthwee

I am trying to make my program more easy to use and not have computer illiterate people struggle to install my program. My question is can a C++ program install ITSELF into another directory upon execution.
I want the program to run, but I also want it to make a backup copy of the same program in a certain directory.

Thanks a lot guys. If you guys want me to post my soure code of my current program I will, but I think this is a self explanatory question and doesn't relate to the context of the sour code.

Thanks a lot for taking the effort to respond.

Yes you can, for example if you were using windows you could use say,
mkdir() to magic up a directory, then you could copy the files in binary mode to that directory. Job done.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.