Solved

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

Posted on 2011-02-26
10
1,230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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 70

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 70

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 70

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Find Files older than 6 months and then ZIP the Files 4 38
need assistance with a VBscript 3 55
Ruby or Python 7 133
Powershell - Setting GPO 8 50
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
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…

752 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