Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

count lines of text in the opened internet window

Posted on 2012-12-20
8
Medium Priority
?
408 Views
Last Modified: 2012-12-27
I need a batch command file to attach to an icon I have on my internet explorer toolbar.

The command needs to count the number of text lines that are in the current internet explorer window.

So it is a text file, but each text file will have a different name and be already opened when I run the batch command to simply count the lines of text in the opened window.
0
Comment
Question by:Danean
[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
  • 4
  • 3
8 Comments
 
LVL 71

Expert Comment

by:Qlemo
ID: 38710438
A .bat/.cmd file does not have access to your Internet Explorer windows. That requires .Net code. Feasible with VBS or PowerShell, or .NET programming languages.
0
 

Author Comment

by:Danean
ID: 38710537
Okay.  Thanks for this information.  I do have powershell.  Do you know what the .Net code would be in order for me to get the line count?
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 38710842
Seems as if that is overly complicated still. I can't get PowerShell to tell which one is the "current openend Internet Explorer window". The best I can do is to show the line count of all URLs staring with FILE://:
(New-Object -COM Shell.Application).Windows() |
  where { $_.FullName -like '*\iexplore.exe' -and $_.LocationURL -like 'file:*'} |
  % { write-output ($_.LocationURL + ": " + ($_.Document.body.innerText -split "`r`n").count) }

Open in new window

0
Command Line Tips and Tricks

The command line is a powerful tool at the disposal of every Linux user. Although Linux distros come with beautiful user interfaces, it's worthwhile to learn the command line because it allows you to do a number of things that you otherwise cannot do from the GUI.  

 

Author Comment

by:Danean
ID: 38711101
the above solution works wonderfully.  However, I am kind of new and am having a few issues still.

1st.  I copied the script above into notepad and saved the files as c:\counttext.ps1.  I programmed by button to launch this file and of course it just opens the text file.  I made sure "all files" was selected before saving it.

2nd.  The solution executes fine from the powershell.

So what am I missing to get my button to run the script and not open the text file?

Thanks.
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 38711139
First try if you can start this command:
    powershell -file C:\counttext.ps1
If that works, use that line for executing the PS code.
0
 

Author Comment

by:Danean
ID: 38721513
I can start the powershell -file c:\counttext.ps1.

I tried adding that line to the beginning of the code you gave and it still does not run.  I also created a counttext file with just that line and I still can't run it.
0
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 38721704
I wanted you to add the   powershell -file c:\counttext.ps1   line to your button code, so it can execute the PS script instead of running the default application (which seems to be notepad, which is quite common).

Again: Call the script with explicit naming powershell.exe, and the file itself should only contain what is in http:#a38710842 .
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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…

704 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