Results 1 to 9 of 9

Thread: Running XCopy using AT command

  1. #1
    Ian Guest

    Running XCopy using AT command

    I have created a cmd file that copies files from one server to another using
    xcopy.
    Running the cmd manually and files get copied over.
    Schedule it using AT or WINAT and it does not copy the files over.
    No error messages are reported.
    I have tried using robocopy but the same thing happens.
    The log on robocopy reports the following error:

    "error 5 (0x00000005) getting file system type of destination access is
    denied"

    I have checked the permissions of the target directory, even went through a
    mapped drive instead of using \\servername etc. I have even checked the
    permissions on cmd.exe and svchost.exe.
    The only difference between running the cmd file manualy and through the
    schedule is manually it used cmd.exe but the AT command uses svchost.exe.

    Any ideas please.
    Cheers


  2. #2
    Todd J Heron Guest

    Re: Running XCopy using AT command

    1) With the AT command the system account has local access rights but none
    on network.
    2) Since jobs run in their own environment, you can't make any assumptions
    about environment variables, including path, which is why every file system
    object should be fully referenced. Ex: use 'C:\winnt\system32\xcopy.exe'
    instead of just 'xcopy'.
    3) Pick a time (hh:mm) in the not-too-distant future so you don't have to
    wait too long. This command will open a 'DOS' console window running in the
    context that all AT jobs run in. In that console window, check the
    environment variables by typing 'set'. Are the environment
    variables what your batch file is expecting? Especially check the value of
    'PATH'. If everything looks OK, type the name of your batch file. Since
    the console window can be scrolled backwards for 9999 lines, you should be
    able to see all the error messages. Fix the errors and try again.
    4) Elevate the context of the batch file to that of an administrator on the
    target system by first mapping a drive to the target system at the beginning
    of the batch file with the Net Use command along with the /user switch.

    --
    Todd J Heron, MCSE
    Windows 2003/2000/NT

  3. #3
    Join Date
    Nov 2004
    Posts
    1

    Re: Running XCopy using AT command

    Thanks for your reply but I am still having problems, it still keeps coming
    up as access is denied when the batch file tries to copy the file over.

  4. #4
    Todd J Heron Guest

    Re: Running XCopy using AT command

    If the batch file runs under the context of the local system account then it
    will not have rights on the remote machine, which is why it throws an
    "Access denied" error message. Run the batch file in the scheduled task
    under the context of an account with the proper permissions on the remote
    machine.

    --
    Todd J Heron, MCSE
    Windows 2003/2000/NT

  5. #5
    Ian Guest

    Re: Running XCopy using AT command

    I have now and everything works.
    Thanks

  6. #6
    Todd J Heron Guest

    Re: Running XCopy using AT command

    You're welcome.

    --
    Todd J Heron, MCSE
    Windows 2003/2000/NT

  7. #7
    Join Date
    Feb 2007
    Posts
    1

    Similar problem

    I just ran into essentially the same problem. I created a .bat file to
    run a copy command so that a backup copy (essentially) of a given file could
    be copied from a Win XP computer on one subnet to a Win Serv 2003 computer
    on another subnet. This failed with an "Access is denied" message. Dumping
    some info to a log file, I discovered that the username present when the
    .bat file is running is "nt authority\SYSTEM". Why (besides the fact that this
    utility was taken by Microsoft and rewritten) is it that the user starting the
    "at" command, or the owner of the .bat file, is not used? I tried using the
    "runas" command to get around this problem, but that command insists on
    a password from the command line, and I need the "at" command to run
    unattended. The target computer does have a SYSTEM user already, and
    that user has full control rights to the directory and file in question.

    Thanks!

  8. #8
    Herb Martin Guest

    Re: Running XCopy using AT command


    "bejmark" <bejmark.2lwh3c@DoNotSpam.com> wrote in message
    news:bejmark.2lwh3c@DoNotSpam.com...
    >
    > I just ran into essentially the same problem. I created a .bat file to
    > run a copy command so that a backup copy (essentially) of a given file
    > could
    > be copied from a Win XP computer on one subnet to a Win Serv 2003
    > computer
    > on another subnet. This failed with an "Access is denied" message.
    > Dumping
    > some info to a log file, I discovered that the username present when
    > the
    > bat file is running is "nt authority\SYSTEM". Why (besides the fact
    > that this
    > utility was taken by Microsoft and rewritten) is it that the user
    > starting the
    > "at" command, or the owner of the .bat file, is not used? I tried using
    > the
    > "runas" command to get around this problem, but that command insists
    > on
    > a password from the command line, and I need the "at" command to run
    > unattended. The target computer does have a SYSTEM user already, and
    > that user has full control rights to the directory and file in
    > question.


    Don't use the "AT" command (it is obsolete) but rather the SchTasks.exe
    command which has a full set of switches for setting Run User name and
    password.


    --
    Herb Martin, MCSE, MVP
    http://www.LearnQuick.Com
    (phone on web site)



  9. #9
    Join Date
    Sep 2007
    Posts
    1
    I have a similar problem to the above. However, i'm running a batch file that calls robocopy and uses the /MIR switch to mirror a 2nd drive physically installed on the machine, to an external hard drive also physically attached to the machine. So in this case, there is no network authentication issue involved.

    The batch process initially seemed to start off ok, but after a few minutes of copying files, came up with the following error:

    Error 5 (0x00000005) Copying File D:/folder/folder/filename.exe
    Access is denied
    Waiting 30 seconds... Retrying...

    I've used this method before, but only on simple setups with just a few files. In this case, about 250GB of files are being mirrored. The first few files this error came up on, weren't important, so i could just delete them, but now i've hit the problem with a file i do need.

    The drive is just a 2nd physical data drive, not the system drive, and the files in question are definitely not in use. I thought it might be an ownership issue, as it shows the owner as an uknown SID. So i took ownership of the file (with the administrator account running the script), and ran the script again, but it stopped at the same file again.

    In fact, i've found that even trying to run the file (which is a .exe file) in this case reports that 'Windows cannot access the specified device, path or file. You may not have the appropriate permission to access the item'.

    I've checked the 'effective permissions' on this file, for the account that tried to open it, and all the boxes are ticked (ie the account has full control)

    Any ideas?
    Last edited by markey164; 26-09-2007 at 10:38 PM.

Similar Threads

  1. Replies: 8
    Last Post: 05-09-2011, 10:41 PM
  2. xcopy command line together with wmplayer command line
    By Aislinn in forum Operating Systems
    Replies: 5
    Last Post: 31-03-2010, 12:13 PM
  3. XCOPY command in bat file doesn't run as scheduled task
    By Laurense in forum Operating Systems
    Replies: 4
    Last Post: 29-03-2010, 06:02 PM
  4. How to run the Xcopy command on XP
    By Mansi gala in forum Operating Systems
    Replies: 3
    Last Post: 31-10-2009, 06:38 PM
  5. Excel - Select Switch Command keeps running
    By wuuhaahaa in forum Windows Software
    Replies: 1
    Last Post: 22-10-2009, 11:31 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,162,150.75094 seconds with 17 queries