Click here to Skip to main content
15,889,860 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi people,
I want to know how can I copy the executed program to another directory, can you help me?
Example: I run my program (test.exe), and on Form1_Load the file test.exe must be copy to another directory!
I hope you understand me...

regards,
KZ
Posted
Comments
Christian Amado 27-Aug-12 10:46am    
What? Why you want to do that?
Killzone DeathMan 27-Aug-12 10:52am    
Because I dont want the user to delete the program, so before he delete, the program has been copy to another directory! Sounds god idea, no?
Dave Kreskowiak 27-Aug-12 11:04am    
No, it's not a good idea.
Killzone DeathMan 27-Aug-12 11:08am    
But why?

Does not sound like a good idea, but...
C#
File.Copy(Application.ExecutablePath, @"D:\Temp\myFile.EXE");
 
Share this answer
 
Comments
Killzone DeathMan 27-Aug-12 10:53am    
why it isnt a good idea? thanks for reply men :)
Kuthuparakkal 27-Aug-12 11:43am    
my 5
It's not a good idea because you're not preventing anything at all. Copying the .EXE file will do nothing for you at all.

If the user has sufficient permissions to alter or delete what's in your applications Program Files folder, you've given the user too many permissions to the application folder. Under Visa and 7, normal users do not have the ability to write or delete anything under Program Files, unless your installer has given them those permissions, in which case YOU have done something very stupid when you wrote your app and installer.

Next, if the MSI installer is written correctly, if the user does delete the .EXE, the files will be replaced by an automatic repair install the next time the application is launched.
 
Share this answer
 
Comments
Killzone DeathMan 27-Aug-12 11:28am    
Dont worry about the installer, there is nothing to install, the user only must have framework 3.5 service pack 1 installed to run the application, nothing more!
And dont worry men, the program has only 1 file, the 'test.exe', and when he execute it, copy the file to another directory wo can't find it, and the user only delete 1 executable file! Nice?
[no name] 27-Aug-12 11:31am    
What prevents the user from deleting the copied file? How does the copied file launch itself next time when the original file is deleted? What is copied and to where and to what depth when the copied file is launched?
Killzone DeathMan 27-Aug-12 11:39am    
The copied file launch itself next time on the 'computer startup'!
When the computer restarts, the windows will run all the programs in the startup folder! And when the program starts the 'Form1' is already hiden, so the user never know if the program is running! And in the 'taskmanager' it dont appear! Nicely and easy, right?
fjdiewornncalwe 27-Aug-12 12:46pm    
So what you're saying is that you're actually writing a worm intended to be self-sustaining and self-replicating. For that you will certainly not get any help here.
Killzone DeathMan 29-Aug-12 5:24am    
I am not a bad person men, its all about experience and evolution! I do not want to do worms and virus for other people!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900