Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically populate IE window 1

Status
Not open for further replies.

sfriday

IS-IT--Management
Feb 23, 2002
211
DE
All,

I want to run a program and write the result to a Blank IE window, I have the following code but it always overwrites and I would rather keep adding to the window I.E.

Process Started
Stopped Process Notepad
Started Process Notepad
Process Finished

Instead all I get is the windows flashing by and it ending up with Process Finished.

CODE:

Set objExplorer = Wsript.CreateObject
"InternetExplorer.Application")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width=400
objExplorer.Height = 200
objExplorer.Left = 0
objExplorer.Top = 0
Do While (objExplorer.Busy)
Wscript.Sleep 200
Loop
objExplorer.Visible = 1
objExplorer.Document.Body.InnerHTML = "Retrieving service information. " _
& "This might take several minutes to complete."
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'Notepad.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
objExplorer.Document.Body.InnerHTML = objProcess.Name & " Terminated"
Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2:Win32_Process")

Error = objWMIService.Create("notepad.exe", null, null, intProcessID)
If Error = 0 Then
objExplorer.Document.Body.InnerHTML = "Notepad was started with a process ID of " _
& intProcessID & "."
Else
objExplorer.Document.Body.InnerHTML = "Notepad could not be started due to error " & _
Error & "."
End If
objexplorer.Document.Writeln "Finished"
Wscript.Sleep 3000
Wscript.Quit
 
instead of this:
Code:
objExplorer.Document.Body.InnerHTML = objProcess.Name & " Terminated"
try this:
Code:
objExplorer.Document.Body.InnerHTML = objExplorer.Document.Body.InnerHTML + objProcess.Name & " Terminated"
Tony
 
Thanks, works a treat.

Now just got to work out how to do a carriage return, no doubt someone has posted that.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top