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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Learning to use the WMI service...

Status
Not open for further replies.

Jetttt

MIS
Nov 3, 2003
32
MX
I am newbie programming with vbscript and with WMI even more. I am programing a script to know if a process its running in a remote computer. this is the code (i am using a hta file to execute the script) :

<html>

<head>

<script type="text/vbscript">

Function IsProcessRunning( strServer, strProcess )
Dim Process, strObject, booValueReturned

booValueReturned= False
strObject = "winmgmts://" & strServer
For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
If strComp(UCase( Process.name ),UCase( strProcess )) = 0 Then
booValueReturned = True
'Exit Function
End If
Next
IsProcessRunning = booValueReturned
End Function

</script>

</head>

<body>

<script type="text/vbscript">
Dim strComputer, strProcess, x
Do
strProcess = inputbox( "Please enter the name of the process (for instance: explorer.exe)", "Input" )
Loop until strProcess <> ""
Do
strComputer = inputbox( "Please enter the computer name", "Input" )
Loop until strComputer <> ""

If( IsProcessRunning( strComputer, strProcess ) = True) Then
document.write("Process " & strProcess & " is running on computer " & strComputer)
Else
document.write("Process " & strProcess & " is NOT running on computer " & strComputer)
End If

</script>


</body>

</html>

This code work fine in my local computer, when i try to access a remote computer the follow error occurs :

Error : Permission denied : 'GetObject'

Both computers have windows XP professional with the service pack 2 installed. I disabled the windows firewall in both computers but didnt work. I have a second hw firewall in my network. This can be the reason of script error?

Regards

JETTTT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top