0

I'm trying to programmatically copy major folders from C: to E:, for the purpose of automatically backing these folders up. It seems to me, as Administrator, I should have full access like root does on Linux, especially for only reading files.

This makes no sense to me. I'm logged in as Administrator, I run powershell as administrator, and I even went to the Control Panel and moved the UAC slider thing all the way down.

So why am I getting access/permissions errors when trying to copy C:\Users or 'C:\Program Files'?

pw222
  • 815
  • 1
  • 6
  • 11
  • This site is for programming related questions, and therefore your question is off-topic here. It's more likely suitable for [su], so you should probably delete it here and ask it there instead. (It will save you some reputation points; many users here think that off-topic questions should be automatically downvoted. I'm not among them, but consider yourself forewarned.) – Ken White Oct 24 '14 at 22:07
  • Thanks for the warning. I'm specifically writing a program/script to copy these files. My code is failing, and I've tracked it down to a permissions issue. I'm not sure how to resolve this issue. – pw222 Oct 24 '14 at 22:09
  • @pw222 - this is actually a scripting/permission issue, and belongs on Server Fault since it's server scripting related. – Erik Funkenbusch Oct 24 '14 at 22:10
  • @KenWhite - Superuser is more for end-user related questions. Server Fault is more for administration related, which I would classify this as. – Erik Funkenbusch Oct 24 '14 at 22:11
  • Your question says "at the command line", which is not a programming/scripting question. The issue is that you're not running on Linux; admins don't automatically have access to all folders simply because they're running under an admin account. (For instance, running an installer still prompts for confirmation that you want to allow the app to change your system, even when you're running as an admin.) – Ken White Oct 24 '14 at 22:11
  • @Erik: I see nothing "server-related" about copying files from the command prompt, other than the fact that it's a server version of Windows. The permissions issues are the same for non-server Windows versions with UAC enabled. This question is simply about copying files from one drive to another and having issues with UAC and permissions. – Ken White Oct 24 '14 at 22:12
  • @KenWhite - you're not going to find many powershell users at Superuser.. they're all over at Server Fault. Because Powershell is an administrative scripting tool. He's doing backups, which is an adminisntrative task. He'll get better answers there. – Erik Funkenbusch Oct 24 '14 at 22:16
  • @Erik: I see nothing that has to do with Powershell here. This is a UAC/permissions issue, whether it's command line, PS, or Windows batch. There's no code that a knowledge of PS would help, either. – Ken White Oct 24 '14 at 22:20

1 Answers1

1

This will get migrated hopefully, but the answer is that Windows is not like Linux. The Administrator account is not like the root account. It does not, by default, have various rights unless you do the equivalent of a sudo, which is to run the prompt at an elevated rights. Right click on your powershell prompt and choose Run as Administrator.

Dragging the UAC slider down does not turn off UAC, it just turns off the UAC warnings when something wants elevation.

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
  • Thank you for the answer, Erik. Strangely, after right-clicking on powershell and choosing Run as Administrator, I still do not get read access to all files. I'm using Tcl, and using the command [file copy -force -- C:/Users E:/test] results in permission denied for certain files nested deep in C:/Users. Using xcopy from the command line results in a similar error. Any ideas? Thanks – pw222 Oct 24 '14 at 22:52
  • @pw222 - it depends on what files you're talking about. Have you looked at the owner and permission attributes? – Erik Funkenbusch Oct 25 '14 at 03:19