Copy text file from one PC (XP OS) to another PC ( Vista OS) Using Dos Copy command


  • I have two PC, One of them running on XP OS and another running on Vista OS.


    Now I want to copy one text file from one PC (XP OS) to another PC (Vista OS) using dos Copy command.


    PC running on Vista OS has Username: Admin and Password: Admin.


    How can I pass Username and Password in Copy command?


    Also I want to do this copy task using “xp_cmdshell” of MS SQL Server 2005. For that I use following code:


    DECLARE @copycmd varchar ( 255)

    PRINT 'Copy Start'

    SET @copycmd = 'copy "f:\temp\test.txt" "\\server04\E\"'

    PRINT @copycmd

    EXECUTE master.. xp_cmdshell @copycmd

    PRINT 'Copy End'


    This code is works if both PC running on XP OS. But it gives “Logon failure: unknown user name or bad password.” Message when I tried this code on XP machine as source and Vista machine as Destination.




    How can I pass Username and Password in Copy command?

    How can I copy text file from XP machine (source) to Vista machine (Destination) using SQL Scripts?


    Is there any alternate way to getting copy task from MS SQL Server 2005? Please help me.



    Wednesday, October 14, 2009 8:02 AM

All replies

  • Hello,

    I am sorry , but i think that you are not on the good forum.

    Anyway, could you tell us how the both computers are linked ? ( WorkGroup or Domain network ) ?
    If at least one machine is with a Home OS, you are obliged to use shared folders.
    To topy files from a PC to another one , you may use FTP or copy thru WMI ( not working with Home Edition )

    If both computers are belonging to a domain network ( with a controller Windows 2003 or 2008 ), it is easier.

    I don't think that you can use SQL Server to copy a file from a PC to another ( SQL Server is not foreseen for this task ). Moreover, you may meet problems with write authorization ( WMI is painful with its security )

    Have a nice day

    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.
    Saturday, October 17, 2009 8:25 PM
  • Have you tried "net use", it probably could be archieved by first establishing the secured UNC connection first with:

    EXECUTE master.. xp_cmdshell "net use x: \\server04\e" /user:<username> /password:<password>"

    Remember to tear down the connection after you are done w/ copying.

    EXECUTE master.. xp_cmdshell "net use /d x:"

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Wednesday, March 24, 2010 5:29 PM