Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

WScript Shell Popup / WScript Echo - How to Pop Message That Disappars

Posted on 2011-02-26
10
Medium Priority
?
1,333 Views
Last Modified: 2012-05-11
I'm hacking together a .vbs that converts a series of .csv to .tsv

I need it to do a pop-up or other message telling me which file it is up to.

I've tried these:

   set WshShell = CreateObject("WScript.Shell")
   Result = WshShell.Popup("Converting " & objFile.Name & " ..." , 3 , , 64)

... and ...

   wscript.echo("Hello")

But I get a Pop-Up where it waits for me to hit OK

I don't want it to wait - I just want it to say the message and then disappear by itself.  Waiting for the OK also holds up the script, so if I have to process a batch of 100 files, someone has to sit there and keep hitting OK

I can run without a status, but then I don't know what it is doing....

Thanks
0
Comment
Question by:drgdrg
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 34989942
Actually the example in your question would work the second parameter is the amount of times in seconds to wait.. so eventually if you waited three seconds it would go away by itself. However you probrably want something better.. You could have your script create a blank page resize it the page small and write the current file as HTML then close the window upon next entry.

Popup Method
http://msdn.microsoft.com/en-us/library/x83z1d9f(v=vs.85).aspx
0
 
LVL 59

Accepted Solution

by:
Bill Prew earned 1600 total points
ID: 34989960
See if this gives you some ideas...

Set objExplorer = WScript.CreateObject("InternetExplorer.Application","IE_")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width=400
objExplorer.Height = 100
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Visible = 1
objExplorer.Document.Body.scroll = "no"
For i = 1 to 5 
    objExplorer.Document.Body.InnerHTML = "Test message #" & i
    wscript.sleep(1000)
Next
objExplorer.Quit

Open in new window

~bp
0
 
LVL 1

Author Comment

by:drgdrg
ID: 34989981
Elq1044 - I agree it "should" work but it doesn't.  I put in a 3 second delay and it never continues until I hit OK.   I don't know if this is a Windows 7 thing or not.

Billprew - will test and post back.  Thanks
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.

 
LVL 1

Author Comment

by:drgdrg
ID: 34990009
Worked great, thanks.  You've given me an idea to add several more indicators.

If you know ...  I'm processing through a CSV file that's been read in.  I want to count up the number of rows read in from the file.  While I can do this (below) it is slow with 1 million rows.  Is there a built in attribute / etc. that I can just reference that already knows the number of rows in the stream?

Thanks

            ' Count the number of rows
            rowcount = 0
            Do Until objFile.AtEndOfStream
                  strLine = objFile.ReadLine
                  rowcount = rowcount + 1
            Loop
            objExplorer.Document.Body.InnerHTML = "Converting " & rowcount & " Rows"
            wscript.sleep(1000)
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 34991338
No, nothing built-in. The issue is that you need to read the whole file (stream) to know how many rows it contains.
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 34991350
While the IE approach showing a updating web page is a good idea, and allows for some GUI tricks like a progress bar, I would be more inclined to use a real Windows Form object for that. However, my personal approach for logging or showing progress is to use the console (cscript), and just echo there (WSript.Echo or WScript.StdOut.Write - the latter errors with wscript, but allows for writing into the same line when used with cscript).
0
 
LVL 71

Assisted Solution

by:Qlemo
Qlemo earned 400 total points
ID: 34991366
Instead of using the number of lines as progress indicator you could use the number of bytes, objFile.size, and count the bytes you already read.
0
 
LVL 59

Expert Comment

by:Bill Prew
ID: 34991421
==> Instead of using the number of lines as progress indicator you could use the number of bytes,
==> objFile.size, and count the bytes you already read.

+1 on this, I was just about to post this (versus number of lines) when I saw that Qlemo mentioned it.  There is an attribute that you can query on the file object to get the size of the file without reading it in, and then as you process each line you can add the length of that line to an accumulator of bytes processed, and compared total bytes to calc progress.

~bp
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 34993124
If you use the byte approach you will have to consider extra bytes that won't be picked up like line feeds which could be two extra bytes per line, one million lines without accounting for line feeds would give you an unpredictable percentage value.
0
 
LVL 1

Author Closing Comment

by:drgdrg
ID: 34993741
Thanks so much. I will test the byte idea - that should be close enough. Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

877 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