WQL - kill process

  • Thread starter Thread starter Alejandro martinez
  • Start date Start date
A

Alejandro martinez

Hi,

this is my first post here.

the question is simple: Can I use WQL to kill a remote process ?

I have tested with something like "delete fromwin32_xxxxx where Name=xxx"
but with no success.

I don´t want to use instance.terminate()

Thanks,
Alejandro
 
I know only Terminate(). If there is any other, i am not aware of it.

Here is the code for Terminate if you want:-


strComputer = "IP or HostName" //Have to Enter by User
strDomain = "Domain" //Have to Enter by User
Wscript.StdOut.Write "Please enter your user name:"
strUser = Wscript.StdIn.ReadLine
Set objPassword = CreateObject("ScriptPW.Password")
Wscript.StdOut.Write "Please enter your password:"
strPassword = objPassword.GetPassword()
Wscript.Echo

Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer(strComputer, _
"root\CIMV2", _
strUser, _
strPassword, _
"MS_409", _
"ntlmdomain:" + strDomain)
' Obtain an instance of the the class
' using a key property value.
Set objShare = objWMIService.Get("Win32_Process.Handle='ProcessID'") //Have to Enter by User

' Obtain an InParameters object specific
' to the method.
Set objInParam = objShare.Methods_("Terminate"). _
inParameters.SpawnInstance_()


' Add the input parameters.

' Execute the method and obtain the return status.
' The OutParameters object in objOutParams
' is created by the provider.
Set objOutParams = objWMIService.ExecMethod("Win32_Process.Handle=''", "Terminate", objInParam) //Have to Enter by User

' List OutParams
Wscript.Echo "Out Parameters: "
Wscript.echo "ReturnValue: " & objOutParams.ReturnValue
 
No. WMI Query Language is SQL-like, but only weakly so - it's really only
designed for filtering returned data automatically. Operations on class
instances can only be performed using methods of the classes. So you're
unfortunately stuck with Terminate().
 
Back
Top