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?

3
  • what if your application is running on a limited user account? by the way just use IO.File.Copy() Commented Mar 14, 2013 at 6:19
  • You're not going to have the necessary privileges to access the Program Files folder. You will have to either create an installer, or follow PM's advice and utilize ClickOnce deployment for your application. Commented Mar 14, 2013 at 6:22
  • forget C:\program files be it desktop Commented Mar 14, 2013 at 6:24

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @JeremyThompson. But If user2166628 ready to change the location as per his recent comment in question. Then it can be useful.
+1 showing some sportsmanship :) ps I deleted my previous comment but I put in my 2 cents in my answer.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.