Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make VBScript's copyfile show a progress bar in XP 1

Status
Not open for further replies.

tunasushi

IS-IT--Management
Dec 8, 2003
7
0
0
US
Hi all,

In Windows XP, I've created a vbscript process that copies a large (100 meg) 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 status of % 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:
- show progress meter and copy file
- prompt "Process complete"

Thanks in advance for any help.

Tony
 
Try something like this:
Code:
srcfile="\path\to\bigfile"
destdir="\\server\share\path\to\dir"
destfile=destdir & "\bigfile"
Set Sh=WScript.CreateObject("WScript.Shell")
msg="Are you sure you wish to copy file?"
If Sh.Popup(msg,0,srcfile,33)<2 Then
  Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
  If fso.FileExists(destfile) Then
    msg=&quot;Do you want to overwrite file?&quot;
    If Sh.Popup(msg,0,destfile,33)>1 Then
      WScript.Quit
    End If
  End If
  Set SA=CreateObject(&quot;Shell.Application&quot;)
  Set NS=SA.NameSpace(destdir)
  NS.CopyHere srcfile,16
  WScript.Echo &quot;Copy done&quot;
End If

Hope This Help
PH.
 
That's exactly how I wanted it. It worked great. Thank you very much.
 
Good call PHV, I notice that a lot of people default to using the FSO for file operations. But for an interactive script the Windows Shell object is often a much better choice.
 
Hello all,

Just a couple of notes.

[1] Shell.application is more heavily localized.
[2] There is a bug of using wildcard for certain OS, I recall.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top