Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: NT
Expertise: Beginner
Feb 18, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

CopyFile API fails with AT command

I have a program that copies a file from Network Drive W: to Local Hard Drive E: using the CopyFile API Function. From the command line, the program works flawlessly. But, schedule the program to run with the AT command, and CopyFile fails with Error #5, "Access is Denied."

I entered in this AT command from the command-line while logged in as Administrator:

at 11:01 /interactive "e:\data\bat\dbu.bat"

The BAT file calls my EXE with the From/To parameters to feed to the CopyFile API function.

The "everyone" group has "Full Control" access to the file being copied and the directory it lives in. The destination directory is on a FAT drive.

By the way, the program works fine if I'm copying the file from one local hard drive to another, from the command-line or from AT.

You have run into one of those basic, but unobvious, security features of NT. AT jobs will NOT run under the security context of the user requesting it (even if you are an administrator). They will run under the security context of whatever you have the Schedule service running under, which is normally the System account. This account has 100% control over the local machine and drives, and 0% control over network drives. The best choice may be to set the Schedule service to run under the account of an account that does have rights to copy the network files.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date