Moving a file to Program Files in any shell ?

Reprobus R 21 Reputation points
2022-08-04T01:09:16.99+00:00

I would like to know how by any means can I move a file to the Program Files folder without being denied within an elevated command or power shell prompt. As I can move a file using File Explorer in Windows from any folder to Program Files but in command prompt or power shell it fails ?

Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. MotoX80 36,291 Reputation points
    2022-08-04T02:35:45.627+00:00

    Please share the exact folder you are trying to move a file to. Is it the root of "C:\Program Files", or is it some subfolder like C:\Program Files\7-Zip"?

    What are the permissions on this folder? Please share the icacls output.

    icacls "C:\Program Files"  
    

    Or

    icacls "C:\Program Files\SomeSubFolder"  
    

    As I tried to explain in your first question, by default it's a matter of permissions, users have read, administrators have full. We forum users do not know if you or some app on your pc has changed permissions. We do not know if the process you are running has UAC elevation or not.

    You also commented about moving a file from a mapped drive. Does the problem also occur when moving a file from a different folder on the C drive?

    By default the explorer should not be elevated. Open 2 command prompts, one with "run as administrator", and one without admin rights. Try a copy command in both windows. Use a source file on the C drive. What results do you get?

    https://learn.microsoft.com/en-us/answers/questions/931969/uac-issue-when-moving-files-between-shells.html

    0 comments No comments

  2. Limitless Technology 39,916 Reputation points
    2022-08-05T07:55:41.58+00:00

    Hello

    Thank you for your question and reaching out. I can understand you are having query related to move file to Program files folder.

    You are able to copy using Windows Explorer because of the Explorer run with your user context and shell or cmd run on different user context or non Admin user context.

    You can use below PowerShell to run using elevated mode.

    Start-Process powershell -Verb runAs

    -----------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.