#177423 - 2007-07-01 07:44 AM
Sending Message via Network
|
ddady
Getting the hang of it
Registered: 2006-09-03
Posts: 98
|
Good Morning All.
I have a domain with few subnets, all subnets connects through IPVPN to the center where i'm at. In every subnet there is one computer which runs one very important application.
There are two things i need to do:
1) To find out whether the application runs or not. 2) To send me a message to notify me about it.
Now, i have tried just to send a message to myself using the SendMessage function but it doesn't work. Is this function uses the Messenger Service which is disabled cause of security issues?
Any help will be appreciated.
|
|
Top
|
|
|
|
#177426 - 2007-07-01 08:38 AM
Re: Sending Message via Network
[Re: Allen]
|
ddady
Getting the hang of it
Registered: 2006-09-03
Posts: 98
|
Thanx Allen,
I'll try the BlAT thing.
BTW, i have searched the Kix Reference before i asked but from some reason the Enumprocess() doesn't exist there.
|
|
Top
|
|
|
|
#177430 - 2007-07-01 02:13 PM
Re: Sending Message via Network
[Re: Lonkero]
|
ddady
Getting the hang of it
Registered: 2006-09-03
Posts: 98
|
mmmm.....OK.
Since i'm new to kix, can someone please explain in short how to use it?
Do i use the exact code? Where it comes in my script? How do i know if the process i need is working?
I'm sorry for all those questions, but as i said. i'm new to kix.
Thanx
|
|
Top
|
|
|
|
#177432 - 2007-07-01 06:41 PM
Re: Sending Message via Network
[Re: ddady]
|
Mart
KiX Supporter
   
Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
|
UDF are add-on function for kixtart. They are cerate by users and can be inserted in the script or called from the script. They will get loaded into memory when the script starts and if all goes well they can be used as any other function native to kix. UDF come as they are and should not have to be changed unless you want something extra from it. Enumproccess in this case does exactly what you want it to.
Here's an example that uses enumproccess to see if notepad is running and does something when notepad is not running You should change notepad.exe in the $pid= EnumProcess("notepad.exe") line to the app you want to monitor and you should add a line that actually uses Blat (or some other mail app) to send you a message that app x is no longer running.
Break on
$pid= EnumProcess("notepad.exe")
If $pid = ""
?"Notepad is NOT running."
Sleep 5
EndIf
;Function EnumProcess($exe, optional $terminate, optional $Computer)
;
;To enumerate OR kill specific processes
;
;$exe: the process name OR numeric PID
;$terminate: null/notnull value to terminate the specified process(es)
;$Computer: the PC to Execute against. Null = local PC
;
;returns an array of PIDs (pipe seperated), If $exe is a process name
;
;To Return the pid of setup.exe
;$pid= EnumProcess("setup.exe")
;
;to terminate all running Internet Explorer windows
;$kill= EnumProcess("iexplore.exe",1)
;
;To terminate a specific exe by it's PID
;$pid=694
;$kill=EnumProcess($pid,1)
;
;Code:
Function EnumProcess($exe, optional $terminate, optional $Computer)
Dim $winmgmts, $ExecQuery, $Process, $id, $GetObject, $
If NOT $computer $computer=@wksta EndIf
$winmgmts="winmgmts:{impersonationLevel=impersonate}!//$COMPUTER"
Select
Case Val($exe)>0
$ExecQuery="select * from Win32_Process where ProcessId='$exe'"
$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
For Each $Process in $GetObject
If $terminate $=$Process.Terminate EndIf
$EnumProcess = $Process.name
Next
$GetObject=''
Case VarType($exe)=8
$ExecQuery="select * from Win32_Process where Name='$exe'"
$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
For Each $Process in $GetObject
If $terminate $=$Process.Terminate EndIf
$id=$Process.ProcessId
$EnumProcess = "$Id" + "|" + "$EnumProcess"
Next
$EnumProcess=Left($EnumProcess,Len($EnumProcess)-1)
$GetObject=''
Case 1
Exit 1
EndSelect
EndFunction
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.
|
|
Top
|
|
|
|
#177437 - 2007-07-02 08:25 AM
Re: Sending Message via Network
[Re: Lonkero]
|
ddady
Getting the hang of it
Registered: 2006-09-03
Posts: 98
|
Thanx MART for the explanation and the example and to the rest of you guys who took the time to help.
|
|
Top
|
|
|
|
#177438 - 2007-07-02 08:37 AM
Re: Sending Message via Network
[Re: ddady]
|
ddady
Getting the hang of it
Registered: 2006-09-03
Posts: 98
|
Thanx Les, That is the reason why this service is disabled. It's better to be safe than sorry, anyhow there is no use for me in the domain with that service so i see no reason to enable it.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 675 anonymous users online.
|
|
|