Sign in to follow this  
Followers 0
AntiVirusGuy

case sensitive processid challenge

10 posts in this topic

I am writing alittle diagnosic which checks the presense of the spysweeper service and the spysweeper program the problem is they have the same name and both run at the same time. the service is SPYSWEEPER.EXE and the program is SpySweeper.exe if I do a prossessexist it can not tell the difference between the two Any ideas?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

from the help

=Tests if two values are equal (case insensitive if used with strings). e.g. If $var= 5 Then (true if $var equals 5)

==Tests if two values are equal (case sensitive if used with strings)

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I still can not distinguish between the two with processexist. It will come back true if the service is runnging. Or I don't understand what you are saying, I am new at this

here is what I am doing

If ProcessExists("SPYSWEEPER.EXE") Then GUICtrlCreateInput("Servicice Running", 130, 340, 125, 20, $WS_DISABLED)

If ProcessExists("spysweeper.exe") Then GUICtrlCreateInput("Program Running", 260, 340, 120, 20, $WS_DISABLED)

Edited by ssebrownatcolby

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

the following solution would require beta

$service = "spysweeper"
If _ServiceExists($service,@ComputerName) Then
    MsgBox(0, "Service Status", $service & " Service Exists:")
Else
    MsgBox(0, "Service Status", $service & " Service Does Not Exist:")
EndIf

Func _ServiceExists($s_ServiceName, $strComputer = "localhost")
; Generated by AutoIt Scriptomatic
    
    Const $wbemFlagReturnImmediately = 0x10
    Const $wbemFlagForwardOnly = 0x20
    Local $colItems = ""
    
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Service where Name = '" & $s_ServiceName & "'", "WQL", _
            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    
    If IsObj($colItems) Then
        For $objItem In $colItems
            Return 1
        Next
        Return 0
    EndIf
    SetError(1)
    Return 0;object not created
EndFunc  ;==>_ServiceExists
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

I get an error in line 16

$colItems = $objWMIService.ExecQuery ("SELE..............

and this script is way to advanced for me to figure out why any ideas?

Share this post


Link to post
Share on other sites

I get an error in line 16

$colItems = $objWMIService.ExecQuery ("SELE..............

and this script is way to advanced for me to figure out why any ideas?

as I posted it requires beta, make sure you run it using beta

one way to check to ensure you are running it in beta would be

MsgBox(0,"AutoIt Version",@AutoItVersion)

if you don't have beta, see link in my signature.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

how do I do that?

just use '==' and 'processlist()'

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

This should do it rather nicely:

Local $PList = ProcessList()
Local $RunningSvc, $RunningPrg

For $I = 1 To $PList[0][0]
    If Not $RunningSvc And $PList[$I][0] == 'SPYSWEEPER.EXE' Then $RunningSvc = 1
    If Not $RunningPrg And $PList[$I][0] == 'spysweeper.exe' Then $RunningPrg = 1
    If $RunningSvc And $RunningPrg Then ExitLoop
Next

Edit: And then:

If $RunningSvc Then GUICtrlCreateInput('Servicice running', 130, 340, 125, 20, $WS_DISABLED)
If $RunningPrg Then GUICtrlCreateInput('Program running', 260, 340, 120, 20, $WS_DISABLED)
Edited by LxP

Share this post


Link to post
Share on other sites

I owe you my first born thanks I need to find a good source to figure out what all these things mean. I read the autoit documentation but do not know how to do these cool things. As usual I am in your debt

This should do it rather nicely:

Local $PList = ProcessList()
Local $RunningSvc, $RunningPrg

For $I = 1 To $PList[0][0]
    If Not $RunningSvc And $PList[$I][0] == 'SPYSWEEPER.EXE' Then $RunningSvc = 1
    If Not $RunningPrg And $PList[$I][0] == 'spysweeper.exe' Then $RunningPrg = 1
    If $RunningSvc And $RunningPrg Then ExitLoop
Next

Edit: And then:

If $RunningSvc Then GUICtrlCreateInput('Servicice running', 130, 340, 125, 20, $WS_DISABLED)
If $RunningPrg Then GUICtrlCreateInput('Program running', 260, 340, 120, 20, $WS_DISABLED)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0