Script som sjekker om applikasjon kjører
Hei!Jeg har begynt på et script som skal sjekke om et program kjører, hvis det gjør det så skal den vise det hvis programmet ikke kjører skal den lukke vindu. Er det noen som kan hjelpe meg videre med scriptet?
//Morten
'********************************************
Set ie = CreateObject("InternetExplorer.Application")
ie.Height = 150
ie.Width = 300
ie.Navigate("about:blank")
ie.MenuBar = False
ie.StatusBar = False
ie.ToolBar = False
ie.Visible = True
Do until not ie.Busy
Loop
Set document = ie.Document
document.Writeln "<HTML>"
document.Writeln "<HEAD>"
document.Writeln "<TITLE>"
document.Writeln "SJEKKER DATA"
document.Writeln "</TITLE>"
document.Writeln "</HEAD>"
document.Writeln "<BODY>"
document.Writeln "<font face=verdana size=2>Overfører data</font>"
document.body.style.cursor = "wait"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServices = objWMIService.ExecQuery _
("SELECT * FROM Win32_Service")
CreateProgressBar colServices.count
i=0
For Each objService in colServices
Progress i
i = i + 1
Next
Dim strComputer, strProcess
Do
strProcess = "OUTLOOK.EXE"
Loop until strProcess <> ""
Do
strComputer = "192.168.214.132"
Loop until strComputer <> ""
If( IsProcessRunning( strComputer, strProcess ) = True ) Then
document.Writeln "<font face=verdana size=2>Overfører data</font>"
document.body.style.cursor = "default"
document.Writeln "</BODY>"
document.Writeln "</HTML>"
Else
document.Writeln "<font face=verdana size=2>Overføring er ferdig</font>"
document.body.style.cursor = "default"
document.Writeln "</BODY>"
document.Writeln "</HTML>"
document.Close
WScript.Sleep 4000
ie.Quit
End If
Private Sub CreateProgressBar (section)
document.Writeln "<P>"
document.Writeln "<TABLE id='progressbar' bordercolor='blue' border='1' rules='none' cellspacing='0'>"
document.Writeln "<TR>"
For i=0 To section - 1
document.Writeln "<TD height='13' width='25'></TD>"
Next
document.Writeln "</TR>"
document.Writeln "</TABLE>"
document.Writeln "</P>"
End Sub
Private Sub Progress (section)
Set objTable = document.all.item("progressbar")
Set row = objTable.rows(0)
Set cell = row.cells(section)
cell.bgcolor = "blue"
End Sub
Function IsProcessRunning( strServer, strProcess )
Dim Process, strObject
IsProcessRunning = False
strObject = "winmgmts://" & strServer
For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
If UCase( Process.name ) = UCase( strProcess ) Then
IsProcessRunning = True
Exit Function
End If
Next
End Function