Options

Script to copy a file from a mapped drive

qwertyiopqwertyiop Member Posts: 725 ■■■□□□□□□□
Im trying to copy a file from a mapped drive. Id like to add thos to our current login script but im having trouble coming up with a script that works.

I have tried using both the Copy and Xcopy commands but it keeps telling me that I have a invalid number of parameters.

I have a feeling that this is happening because I cant access the mapped drive via the command prompt.

Does anybody have any idea how I could make this work?

Comments

  • Options
    RobertKaucherRobertKaucher Member Posts: 4,299 ■■■■■■■■■■
    Unless I am mistaken, mapped drives are mapped at login. This probably means that you are not able to access the drive yet. Try copying from the location using [URL="file://\\server\share\file.exe"]\\server\share\file.exe[/URL]
  • Options
    qwertyiopqwertyiop Member Posts: 725 ■■■□□□□□□□
    Well this is what I have so far:
    s:
    cd MHD Standards\2009 Survey Standards\MHD (C3D) Survey Baseplan Files\MHD (C3D)\Templates
    xcopy MHDBP(C3D).dwt %appdata%\autodesk\c3d 2009\enu\Template /s /e
    Everything works until it gets to XCOPY. it says invalid number of paremeters
  • Options
    kalebkspkalebksp Member Posts: 1,033 ■■■■■□□□□□
    Try putting quotes around the second path in the xcopy command:
    s:
    cd MHD Standards\2009 Survey Standards\MHD (C3D) Survey Baseplan Files\MHD (C3D)\Templates
    xcopy MHDBP(C3D).dwt "%appdata%\autodesk\c3d 2009\enu\Template" /s /e
    
  • Options
    rsuttonrsutton Member Posts: 1,029 ■■■■■□□□□□
    I just ran xcopy /? and noticed this about the switches you are using:

    /S Copies directories and subdirectories except empty ones.
    /E Copies directories and subdirectories, including empty ones.

    It would seem having them both in place as you do would be contradictory. Also, you may need to use upper case letters - I don't recall if it's case sensitive.
  • Options
    qwertyiopqwertyiop Member Posts: 725 ■■■□□□□□□□
    kalebksp wrote: »
    Try putting quotes around the second path in the xcopy command:
    s:
    cd MHD Standards\2009 Survey Standards\MHD (C3D) Survey Baseplan Files\MHD (C3D)\Templates
    xcopy MHDBP(C3D).dwt "%appdata%\autodesk\c3d 2009\enu\Template" /s /e
    


    Thanks for the help, im surprised that none of the examples that I found had the quotes
  • Options
    RobertKaucherRobertKaucher Member Posts: 4,299 ■■■■■■■■■■
    The reason is because of the space between c3d and 2009.
  • Options
    qwertyiopqwertyiop Member Posts: 725 ■■■□□□□□□□
    DO you happen to know if theres a switch that will tell it to overight a file if it already exists?
  • Options
    RobertKaucherRobertKaucher Member Posts: 4,299 ■■■■■■■■■■
    /-Y is what you want.
  • Options
    Hyper-MeHyper-Me Banned Posts: 2,059
    And as an side, if you are trying to copy a file as the system with a script you have to give the computer object read permissions to the share where the file is located and then copy from the unc path such as \\server\share\file.exe , as Robert pointed out.
  • Options
    Fugazi1000Fugazi1000 Member Posts: 145
    You might also like to consider ROBOCOPY.EXE. More options than other copy methods and more robust in the event of disconnects etc.
  • Options
    qwertyiopqwertyiop Member Posts: 725 ■■■□□□□□□□
    I was able to get the my 1st of my script working but I have to review my 2nd script because it is failing on the xcopy portion.
  • Options
    brad-brad- Member Posts: 1,218
    Synctoy lets you synchronize, echo, or contribute to folder pairs. You can thrown a switch on to the end of the shortcut and set it as a scheduled task...works similarly as a batch copy command...but with more options.

    as fair as y our standard batch script goes...i did something like that a while back and it had problems with the multiple worded folder names, so I had to truncate the folder name with ~1 to make that work.
  • Options
    tierstentiersten Member Posts: 4,505
    qwertyiop wrote: »
    Thanks for the help, im surprised that none of the examples that I found had the quotes
    It is because quoting paths which have spaces in isn't specific to the copy command.
Sign In or Register to comment.