Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

msgbox for progress

Posted on 2008-11-12
7
Medium Priority
?
373 Views
Last Modified: 2012-05-05
Is there a way to create a msgbox in a vbs script to show the progress of a action.

For example:

If I had something in the such as copying a very large file somewhere that would take 5 or 10 minutes, can a msgbox come up while it is working, then close and continue. Don't want a box to come up where you have to click OK to close it and continue.

Thanks,

0
Comment
Question by:bt707
  • 4
  • 3
7 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 22943832
Hi, this should do it.  It shows the standard windows progress bar:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_23213819.html

Regards,

Rob.
0
 

Author Comment

by:bt707
ID: 22944187
Hi Rob,

I tried that but did not work, getting a error path not found for some reason, I have the correct paths in and full rights to those directories. Do you have any idea why I would get a path not found error, it's coming from this line.
Set objSourceFolder = objFSO.GetFolder(strSourceFolder)

Here is what I tried

'=========================
strSourceFolder = Replace(WScript.ScriptFullName, WScript.ScriptName, "") & "D:\temp\test"
strTargetFolder = Replace(WScript.ScriptFullName, WScript.ScriptName, "") & "D:\temp\test2"
 
If Right(strSourceFolder, 1) <> "\" Then
        strSourceFolder = strSourceFolder & "\"
End If
If Right(strTargetFolder, 1) <> "\" Then
        strTargetFolder = strTargetFolder & "\"
End If
 
Const FOF_CREATEPROGRESSDLG = &H10&
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
Set objSourceFolder = objFSO.GetFolder(strSourceFolder)
Set objShell = CreateObject("Shell.Application")
Set objTargetFolder = objShell.NameSpace(strTargetFolder)
If Not objTargetFolder Is Nothing Then
        'MsgBox "Copying " & objSourceFolder.Path & " to " & strTargetFolder
       
        objTargetFolder.CopyHere objSourceFolder.Path, FOF_CREATEPROGRESSDLG
Else
        MsgBox "There was an error finding " & strTargetFolder
End If
MsgBox "Done"
'==================


Thanks,
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22944551
Hmmm, no not really....above that line
Set objSourceFolder = objFSO.GetFolder(strSourceFolder)

put this
strSourceFolder = InputBox("Source folder is:", "Source Folder", strSourceFolder)

and then see if you can copy and paste that path to a Windows --> Run box and find it....

Regards,

Rob.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:bt707
ID: 22944645
That is the problem, probably a easy one for you but I'm not sure what to fix.

The box give me this for the path.

Source folder is:
D:\TEMP\D:\temp\test\

Thanks,


0
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 22944904
Oh yeah!  I see what the problem is....

You have this:
strSourceFolder = Replace(WScript.ScriptFullName, WScript.ScriptName, "") & "D:\temp\test"

but the problem there is that this part
strSourceFolder = Replace(WScript.ScriptFullName, WScript.ScriptName, "")

returns the current folder that the script is running from.

Remove those and use just this:
strSourceFolder = "D:\temp\test"
strTargetFolder = "D:\temp\test2"

Regards,

Rob.
0
 

Author Closing Comment

by:bt707
ID: 31516037
OK, I see now. That fixed it. Learned a few new things here.
Works very well now.

Thank you very much.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22945107
No problem at all. Thanks for the grade.

Regards,

Rob.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question