Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Dec 2003
    Location
    Providence, Rhode Island, USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Make VBScript's copyfile show a status bar in XP

    In Windows XP, I've created a vbscript process that copies a large file to a server using copyfile. The user double-clicks an icon pointing to the script when it's time to copy the file. Although it works, the problem is that there is no indication that it's working or when it's done.

    I don't work with vbscript too often, so it's not my area of expertise. I'd like to know if the following can be done in vbscript with a progress bar showing a percent complete, and if so, how to implement it.

    - User doubleclicks icon
    - prompt "Are you sure you wish to copy file?"
    - check for existence of file on server
    - if file exists:
    - prompt "Do you want to overwrite file?"
    - if yes:
    - showing a progress meter, copy file
    - prompt "Process complete"

    Thanks in advance for any help.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Make VBScript's copyfile show a status bar in XP

    VBScript doesn't have a progress bar, and it would be difficult to multithread so that you could be copying a file and simultaneously looking at how much had been copied. I wonder if there's a way to invoke the "flying document" bar from Windows Explorer. It doesn't show progress, but at least it indicates that something is happening. Hmmm...

  3. #3
    New Lounger
    Join Date
    Dec 2003
    Location
    Providence, Rhode Island, USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Make VBScript's copyfile show a status bar in XP

    This is a late reply, but if anyone else is looking for this information, I figured I'd include it here. I discovered that the trick to my request is to use the CopyHere method, not the CopyFile. Here's the code:

    <pre>sourcefile="SERVERSourceDirBigFile.Dat"
    destinationdir="SERVERTargetDir"
    destinationfile=destinationdir & "BigFile.Dat"
    Set Sh=WScript.CreateObject("WScript.Shell")
    msg="Are you sure you wish to copy the file?"
    If Sh.Popup(msg,0,"Copy Your File",36)<2 Then
    Set fso=CreateObject("Scripting.FileSystemObject")
    If fso.FileExists(destinationfile) Then
    msg="WARNING! This file exists. Do you want to overwrite?"
    If Sh.Popup(msg,0,"Copy File",36)>1 Then
    WScript.Quit
    End If
    End If
    Set SA=CreateObject("Shell.Application")
    Set NS=SA.NameSpace(destinationdir)
    NS.CopyHere sourcefile,16
    WScript.Echo "File copy completed."
    End If
    </pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •