WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

UAC

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

FileCopy and UAC

 Keywords: FileCopy Access Denied UAC Win7 Vista 

Question:

I am trying to simply copy some files from my network G:\ drive to my local C:\program Files\{Application name}

I get a permission problem. How can I get WinBatch script to run against a folder that doesn't have permissions. Is there a "run as administrator" feature in Winbatch?

This is a Windows 7 Box. When I debug, it says I don't have permissions to put the file in that directory. Is there a workaround?

When I try to copy the file myself, I receive a permissions dialog box. Stating I need elavated permissions to copy the file.

The script sees the mapped drive fine. The problem is when it goes to copy the files to the C:\program Files\ area because of the UAC set at medium. the script fails.

I have been reading many posts about the UAC issue.

All I want to do is simply copy a bunch of files. Is there an easy way of doing this?

Answer:

The easiest solution is to turn off UAC but that is not always an option.

If you are compiling your script and the compiled script always runs under an admin account then the next easiest solution is to compile the script with the 'requireAdministartor' or 'highestAvailable' manifest setting.

If the compiled script will run under a standard user account then 'requireAdministrator' manifest setting will be need along with user knowledge of an administrative password. You will then get the UAC prompt just like you do when you copy the files manually but you wont get the error.

If you need to avoid the UAC prompt altogether then this suggestion is your best option that doesn't involve spending a lot of money. We have found the most consistently reliable option is to use the Windows Task Scheduler to run an install as a logon task. Basically this causes the script to run as a service and you will not receive any UAC prompts when running from the task scheduler. You will need to familiarize yourself with the Windows Task Scheduler.

UAC is here to stay so it's a good idea to continue reading about UAC until you acquire a modicum of understanding. It will save you a lot of script writing grief down the road.


Article ID:   W18313
Filename:   FileCopy and UAC.txt
File Created: 2011:06:07:13:41:36
Last Updated: 2011:06:07:13:41:36