Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


[resolved]update user screen while external app runs (CreateObject("WScript.Shell").Run "")

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> [resolved]update user screen while external app runs (CreateObject("WScript.Shell").Run "")
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 [resolved]update user screen while external app runs (C... - 8/17/2007 7:14:07 AM   
  CondoPC


Posts: 118
Score: 0
Joined: 7/23/2007
Status: offline
I have written a HTA application for reseting services on remote computers. During the stop or start service process, my script updates a text in a text box to simulate a progress bar. Everytime the script completes a wait loop, it appends the string and updates the textbox with the appended text.

This works great as long as the methods being performed are within the script. The problem I have is that I launch IISRESET to reset the webservices on remote servers. I do this because it handles the service dependancies better/easier. When my script launches it, it is a synchronous process, meaning my script has to wait until it completes before it can continue.

My question is, how can I perform this function and update the screen whille IISReset is running. Basically making a script multithreaded. The following are parts of my script with the needed functions. I have also included the service control function so that you can see the concept of the screen update. If the entire script is needed, I can post it so that it can be troubleshot, but I am interested more in concept than specifics. (I know that I could just allow the executed app to appear on the screen, updating the user with progress, but I want to make the whole tool/application uniform in the way it displays status.)


      

< Message edited by CondoPC -- 8/17/2007 3:12:35 PM >
 
 
Post #: 1
 
 RE: update user screen while external app runs (CreateO... - 8/17/2007 9:52:24 AM   
  CondoPC


Posts: 118
Score: 0
Joined: 7/23/2007
Status: offline
I'm thinking that maybe the Exec method may allow me to run asychronously like the service control funtion

here is the working example from MSDN http://msdn2.microsoft.com/en-us/library/ateytk4a.aspx. I assume that the script is performing the sleep loop until the application exits. This would work fine for my IISReset since it exits when finished.

Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")

Set oExec = WshShell.Exec("calc")
Do While oExec.Status = 0
    WScript.Sleep 100
Loop


(in reply to CondoPC)
 
 
Post #: 2
 
 RE: update user screen while external app runs (CreateO... - 8/17/2007 2:10:27 PM   
  dm_4ever


Posts: 2663
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
You might be able to use the Exec method and use your sleep function to give the HTA time to update appropriately.

Dim objShell : Set objShell = CreateObject("WScript.Shell")
Dim objExec : Set objExec = objShell.Exec("ipconfig /all")

Do Until objExec.StdOut.AtEndOfStream
   WScript.Echo objExec.StdOut.ReadLine
   WScript.Sleep 1000
Loop

For more control I would modify the ServiceControl function to handle dependencies as well or you could also use InternetExplorer to provide progress information.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to CondoPC)
 
 
Post #: 3
 
 RE: update user screen while external app runs (CreateO... - 8/17/2007 2:56:05 PM   
  CondoPC


Posts: 118
Score: 0
Joined: 7/23/2007
Status: offline
When I first wrote this script, I was in a hurry and gave up on some of the error control and troubleshooting. With that said, after the fourth rewrote/rework of the service control functions, I left them as shown and inserted the use of IISRESET to handle IIIS. This was because I had services (IISADMIN) that had dependants (HTTP, HTTPS, WWW) that also had dependants (WWW). Because WWW wasn't stopped, HTTPS couldn't stop (or something like that).

Since then (about 3 weeks), I have learned quite a bit and have the time to review the script and clean it up. I agree with you that the Exec method would work, and I successfully tested it. I also took the time to rewrite a bunch of the functions so that I can find dependants better. The following is an example of the reworked stop services function which also will poll for service state.


      

Instead of using standard msgbox or wscript.echo command, I always put the text I want to display in a sub called DisplayOutput. This allows me to reuse code snippets without replacing all the output. I just modify the DisplayOutput sub to handle the medium i need. Here is the following so that the code above will display.

      


Note: in response to a few posts about finding the state of a service - if you uncomment the line:
'sP = "[" & iResult & "]"
it will show you that the InterrogateService method does indeed give you different states of a service as it goes through its shutdown. It's just not as verbose, but i like it better than requerying WMI, which I think can be heavy on slower/bogged systems or across the network. I wrote these scripts to manage services across a farm and to perform the service resets across numerous servers at once.

Once I finish tweaking the display and cleanse it of company data, I will post it for use. It's a good framework tool to expand on.

< Message edited by CondoPC -- 8/17/2007 4:19:42 PM >

(in reply to dm_4ever)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> [resolved]update user screen while external app runs (CreateObject("WScript.Shell").Run "") Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts