Solved

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

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

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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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 51

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

744 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

11 Experts available now in Live!

Get 1:1 Help Now