How do I call DOS Copy from ActiveX vbscript file

  • I should probably know how to do this without asking for help, but how do I call a DOS Copy command from an ActiveX vbscript within a DTS package?

    xp_cmdshell?????

    Please help.

    Thanks,

    Karen

    karen M Mason


    Karen M Mason

  • Have you tried to work on FileSystemObjects?

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/jsmthcopyfile.asp

  • quote:


    Have you tried to work on FileSystemObjects?

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/jsmthcopyfile.asp


    Yes, I used FileSystemObjects to create a sequence of three files. Now I need to concatenate these three files into one output file. I don't think the FSO CopyFile command will support concatenation, but I'm not sure. Do you know?

    Thanks so much for responding!

    Karen

    Karen M Mason


    Karen M Mason

  • Maybe you could try to create the new file and append the content of another three files into the new file.

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/jsmthopenastextstream.asp

    Maybe some VB Guru can follow up this.

    Edited by - allen_cui on 09/12/2003 08:54:05 AM

  • Can't remember if you can shell from VBScript. Could always do it via xp_cmdshell - just pass 'copy file1 + file2 file3', I think is the syntax.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • If you want to execute a DOS command in VBScript you need to create a Windows Shell object. Then you can execute any command you want.

    Eg:

    Dim WshShell, oExec

    Set WshShell = CreateObject("WScript.Shell")

    Set oExec = WshShell.Exec("calc")

    If you're not interested in any return value, just leave out the Set oExec from the above example.

    As you are creating these files using the FileSystemObject, why don't you create the concatenated file while you're creating the other three?

    Hope this helps

    Phill Carter

    --------------------

    Colt 45 - the original point and click interface

    Edited by - phillcart on 09/14/2003 6:16:55 PM

    --------------------
    Colt 45 - the original point and click interface

  • Thanks Phil, I shoulda remembered that! A nice side affect of that shell is you can shell and continue, or shell and wait. Nice to be able to easily control the behavior.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • quote:


    If you want to execute a DOS command in VBScript you need to create a Windows Shell object. Then you can execute any command you want.

    Eg:

    Dim WshShell, oExec

    Set WshShell = CreateObject("WScript.Shell")

    Set oExec = WshShell.Exec("calc")

    If you're not interested in any return value, just leave out the Set oExec from the above example.


    Thanks for the pointer to Wscript. I read about this prior to posting but surmised that a

    little knowledge could be dangerous in my hands. Now that you've suggested using it, I'll investigate further.

    quote:


    As you are creating these files using the FileSystemObject, why don't you create the concatenated file while you're creating the other three?

    Hope this helps

    Phill Carter

    --------------------

    Colt 45 - the original point and click interface

    Edited by - phillcart on 09/14/2003 6:16:55 PM


    Concatenation of multiple files was a bandaid for yet another problem I couldn't resolve.

    You're right. I should create the output file while creating the others. I've struggled with this DTS package for so long that I'm not approaching the task very logically anymore.

    Yet again, you've set me on the right track.

    Thanks much

    BTW: I don't understand any of those Irish jokes

    Karen M Mason


    Karen M Mason

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply