SQL Server Developer Center > SQL Server Forums > SQL Server Samples and Community Projects > Copy text file from one PC (XP OS) to another PC ( Vista OS) Using Dos Copy command
Ask a questionAsk a question
 

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

  • Wednesday, October 14, 2009 8:02 AMAmiPatel Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    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.

     

    So,

     

    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.

     

    Thanks.

All Replies

  • Saturday, October 17, 2009 8:25 PMPapy Normand Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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.