Chandra
Chandra

Reputation: 37

Qt5 duplicate (copy) an executable file

New to Qt. Kindly bear if this question too naive. On Windows OS environmemt, I have Qt Dialog frame application which has "Duplicate" - push button . In the same directory, there is Qt application - (a Dialog widget with close button) A1.exe. Now, after click of Duplicate button, would like to copy the A1 exe and rename it as B1.exe (on the fly) in the same directory and execute it.

So, at the end two Qt applications (A1 exe and B2) running till manually cancel it. After brief research, there seems to be 2 optoins to do - QFile copy or QProcess. or any other method ? Appreciate any quick (detailed as well) thought!
Thanks

Upvotes: 0

Views: 239

Answers (2)

Mike
Mike

Reputation: 302

char name = 'A';
do {
INCREMENT NAME...
} while ( name + 1.exe ) exists...

Then do qfile copy from the original to the new file path made in the loop. From therw qprocess is what youre looking for to launch.

Upvotes: 1

It is a bad idea to assume that you have write access to any location where executables are stored. On most modern operating systems, installing applications requires granting of temporary elevated privileges. On Windows specifically, you simply cannot assume write access to the install location, period. Anyway, you don't need to copy the executable. Why would you? If you think of modifying the executable: sorry, that doesn't work either. You'll have to sign your executables, no matter what platform you deploy to (linux has package signatures too!). Modifications will break things. Just don't.

Upvotes: 1

Related Questions