Solved

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

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

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
 
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 68

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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 68

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 68

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 52

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now