Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


RE: Dynamic Activity Window

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,32390
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> RE: Dynamic Activity Window
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  1 2 [3]
Login
Message << Older Topic   Newer Topic >>
 RE: Dynamic Activity Window - 1/3/2007 11:37:10 PM   
  TonyLongson

 

Posts: 1
Score: 0
Joined: 5/30/2006
Status: offline
Excellent script DiGiTAL.SkReAM !!!

There's only one thing I don't understand: why do you do ExecuteGlobal "Dim oShell, oFSO, oEnv" instead of defining them alongside oBarCat?

Also, you could avoid the registry access issues if you used the .run file to hold the status text instead.

Tony Longson.

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 41
 
 RE: Dynamic Activity Window - 1/4/2007 1:14:38 AM   
  DiGiTAL.SkReAM


Posts: 1171
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
Thanks, Tony.
To answer your questions, I Dim'med those variables via ExecuteGlobal as a hack, since I needed them to be there, but I didn't want to have them declared until after the StartBar sub was run.

And the registry access is there because it is so much faster than dumping text to a file.  When I was using text files to hold the status text, in earlier incarnations of the class, I found that after a long run time, the chances of my reading and writing to the file at the same time increased, and eventually, it would crash.  by using the registry, the processing is much faster (try timing registry i/o vs. file i/o sometime), and I don't have that worry.  I have found that if a script is processing in a linear fashion, using a text file as a temp memory storage area is sometimes ok, but when you have two or more processes accessing that same file... things can get a bit dicey.


_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to TonyLongson)
 
 
Post #: 42
 
 RE: Dynamic Activity Window - 5/20/2007 12:02:51 AM   
  phil999

 

Posts: 38
Score: 0
Joined: 5/4/2007
Status: offline
this is probably a stupid question....

I have an hta which installs software via a list box and the listbox calls a sub example

Sub installmediaplayer11
objfso.CopyFile"\\server\sw-package$\Silent_Software_Installs\wmp11-windowsxp-x86-enu.exe", "C:\IT_SOFTWARE\wmp11-windowsxp-x86-enu.exe"
winsh.Run("C:\IT_SOFTWARE\wmp11-windowsxp-x86-enu.exe /Q:A /R:N")
End Sub

What i would like to do is have a progress bar whilst the install is happening.  How would i go about doing this using this code?

Thank in advance

Phil

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 43
 
 RE: Dynamic Activity Window - 5/21/2007 12:13:40 AM   
  DiGiTAL.SkReAM


Posts: 1171
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
quote:

ORIGINAL: phil999
this is probably a stupid question....
I have an hta which installs software via a list box and the listbox calls a sub example

      
What i would like to do is have a progress bar whilst the install is happening.  How would i go about doing this using this code?


Like this:
First, tack the progressbar class onto the end of your code.  Then, modify the above Sub to look like this:

      


_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to phil999)
 
 
Post #: 44
 
 RE: Dynamic Activity Window - 5/21/2007 1:19:56 AM   
  phil999

 

Posts: 38
Score: 0
Joined: 5/4/2007
Status: offline
Thanks for your help i am having a few problems getting the class in the right place it should be the last thing before the </script> command right?

oBarCat.Add oBarCat.Count, "</SCRIPT>"

Thats the line it seems to throw back.

< Message edited by phil999 -- 5/21/2007 1:22:28 AM >

(in reply to DiGiTAL.SkReAM)
 
 
Revisions: 1 | Post #: 45
 
 RE: Dynamic Activity Window - 5/21/2007 4:22:12 AM   
  phil999

 

Posts: 38
Score: 0
Joined: 5/4/2007
Status: offline
OK so after more testing i have worked out it is because i am running it from an hta if i put it in a vbs file it works fine but when in an hta it fails.  Any thoughts?

(in reply to phil999)
 
 
Post #: 46
 
 RE: Dynamic Activity Window - 5/21/2007 4:43:48 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
How does it fail? What happens?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to phil999)
 
 
Post #: 47
 
 RE: Dynamic Activity Window - 5/21/2007 4:54:42 AM   
  phil999

 

Posts: 38
Score: 0
Joined: 5/4/2007
Status: offline
Unterminated string contrant on line 584

line 584             oBarCat.Add oBarCat.Count, " End Sub"
line 585             oBarCat.Add oBarCat.Count, "</SCRIPT>"

it works fine if it is in a vbs but i am trying to run it from an inside an HTA

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 48
 
 RE: Dynamic Activity Window - 5/21/2007 4:57:24 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Hmmmm....that is odd given the lines that you posted. Could you post some more lines from around there?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to phil999)
 
 
Post #: 49
 
 RE: Dynamic Activity Window - 5/21/2007 5:00:37 AM   
  phil999

 

Posts: 38
Score: 0
Joined: 5/4/2007
Status: offline
What i have just before the </SCRIPT> is

the class from the first post

------------------


      

I even tried a new hta


      

(in reply to DiGiTAL.SkReAM)
 
 
Revisions: 1 | Post #: 50
 
 RE: Dynamic Activity Window - 5/21/2007 5:21:41 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
I would think about pulling the dictionary creation part out into a seperate script to make it easier to find the problem.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to phil999)
 
 
Post #: 51
 
 RE: Dynamic Activity Window - 5/21/2007 5:47:23 AM   
  DiGiTAL.SkReAM


Posts: 1171
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
This code was never meant to be run from inside another HTA. 
First off, you are including the example code at the beginning, which includes WScript.Sleep commands that are invalid in an HTA.
Secondly, the section where it tries to bring itself to the forefront performs an appactivate on mshta.exe.  Well, if you already have an HTA open, mshta.exe is already being used.  When the Progressbar ends, it kills the mshta.exe process - which would kill your original HTA as well.

It is kinda like saying "This snowsuit doesn't keep me dry when I am snorkeling!  Snow is just frozen water, so it should work!  How do I fix it?"
The only answer is: don't use it while snorkeling!

_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to ebgreen)
 
 
Post #: 52
 
 RE: Dynamic Activity Window - 5/21/2007 9:41:16 AM   
  phil999

 

Posts: 38
Score: 0
Joined: 5/4/2007
Status: offline
ok so i would have to run as an external vbs file?  As i know it works that way but based on the following how would i call it?


      

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 53
 
 RE: Dynamic Activity Window - 5/22/2007 1:04:12 AM   
  DiGiTAL.SkReAM


Posts: 1171
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
The same wayt hat you would call any other external vbs file.
Perform a search in the fora for
filesystemobject
arguments
wscript.shell
and then read some of the docs.
You are looking for a way to run an external vbscript from another, while passing arguments to it.  I can provide the class, but it is up to you to learn how to use it in conjunction with your own code.

_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to phil999)
 
 
Post #: 54
 
 RE: Dynamic Activity Window - 1/31/2008 3:42:47 AM   
  KroBaar

 

Posts: 2
Score: 0
Joined: 1/31/2008
Status: offline
I know this thread is old, but I just came across this progressbar the other day and I like the way it works, for the most part.  I have a few comments regarding it though. 
1). Throughout the code, every pointer to an object created is never set to Nothing when you are finished, this poses a memory leak, does it not?  As well as using the If CreateObject(...), how is that object released?  Shouldn't it be set to some variable x, then set to Nothing when finished?
2). You mentioned to a user that this code wasn't intended to run inside an HTA, which I agree, however, the code can be executed from within an HTA by used of wscript.shell and the run method.  In terms of it killing the mshta.exe process, I acutally couldn't find where you do that, and have noticed that if I have multiple HTA applications running, only progressbar closes.  However, your call to oShell.AppActivate causes every HTA application to be activated.  To Activate only the progressbar, I modified the code a little.  I modified your For loop from:

oBarCat.Add oBarCat.Count, "Set cItems = oWMIService.ExecQuery(" & Chr(34) & "SELECT Name, ExecutablePath FROM Win32_Process where Name = 'mshta.exe'" & Chr(34) & ")"
oBarCat.Add oBarCat.Count, "   For Each oItem in cItems"
oBarCat.Add oBarCat.Count, "      oShell.AppActivate oItem.Handle"
oBarCat.Add oBarCat.Count, "   Next"

to:

oBarCat.Add oBarCat.Count, "  Set cItems = oWMIService.ExecQuery(" & Chr(34) & "SELECT Name, ExecutablePath, CommandLine FROM Win32_Process where Name = 'mshta.exe'" & Chr(34) & ")"
oBarCat.Add oBarCat.Count, "   For Each oItem in cItems"
oBarCat.Add oBarCat.Count, "  If oItem.CommandLine = document.Location.pathname Then"
oBarCat.Add oBarCat.Count, "      oShell.AppActivate oItem.Handle"
oBarCat.Add oBarCat.Count, "  End If"
oBarCat.Add oBarCat.Count, "   Next"

This will only activate the HTA that matches the filename running the code, hence progressbar. For that to work, I had to change the select statement and add the column CommandLine to the list you were selecting.

Other mods made:
You hard coded a path on the C: drive which doesn't happen to exist for the workstations at the Corporation I work for:

sProgressBarHTAFileKiller = "c:\temp\htakiller.vbs"

so I made use of an object you were using thoughout for the environment variables and changed the line to:

sProgressBarHTAFileKiller = oEnv("TEMP") & "\htakiller.vbs"

As well, as mentioned before with setting object pointers to Nothing, couldn't this be handled in the class terminate procedure (which would have to be added of course, ProgressBar_Terminate() )?  Other than that, it seems to do what I was looking for.  : )

(in reply to DiGiTAL.SkReAM)