Solved

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

Posted on 2011-02-26
10
1,209 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 54

Accepted Solution

by:
Bill Prew earned 400 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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 69

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 69

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 69

Assisted Solution

by:Qlemo
Qlemo earned 100 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 54

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
powershell script 9 67
randomize data from excell cell 15 48
AWK Code gives empty file, why? 12 37
Vbscript & Batch: restart servers with delay condition 2 30
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…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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 tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

820 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