0

When execution an application for the first time, I want this running applicationto be copied to C:\Program Files\

Say I give this application to my friend then he executes it for the first time and this application must do the copy to C:\Program Files\

How to code it?

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321

2 Answers2

1

You are trying to create a Click Once kind of application. Check the link Click Once Deplyment

PM.
  • 1,735
  • 1
  • 30
  • 38
  • Thanks @JeremyThompson. But If user2166628 ready to change the location as per his recent comment in question. Then it can be useful. – PM. Mar 14 '13 at 06:42
  • +1 showing some sportsmanship :) ps I deleted my previous comment but I put in my 2 cents in my answer. – Jeremy Thompson Mar 14 '13 at 06:53
0

You cannot move an EXE file while it is being executed, you will either:

  • have code that copies the EXE to another location

IO.File.Copy()

  • or have an installer

Click Once installs to a really obsecure location, not program files. It does NOT require admin.

If you add a MSI setup project to your solution you can see this answer to hardcode the install path to C:\Program Files\

If you choose the MSI solution you will need Admin to install. Because the setup.exe is responsible for the downloading/installing components (such as dotnet) it requires Admin to be executed.

If you know the PC your application is going to be installed on already has the .Net Framework & etc then the easiest way to avoid the UAC prompt is to run the MSI not the setup.exe. Running the MSI wont ask for admin.

You can also follow this answer to make your upgrades install to the same folder.

Community
  • 1
  • 1
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321