DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: FBSL - Process killer  (Read 7,372 times)

Gerome

  • Charter Honorary Member
  • Joined in 2006
  • ***
  • Posts: 154
FBSL - Process killer
« on: April 07, 2006, 05:00 PM »
' ------------------------------------------------
' // PROCESS KILLER
' // April, 7th 2006
' // By Gerome GUILLEMIN
' // Requires : WSH COM interface installed
' ------------------------------------------------

Process_killer.fbs
Code
#Option Explicit

If standalone = false Then
    Fbsl2exe( Command(1) )
    Exitprogram(1)
End If

#DllDeclare kernel32( "GetEnvironmentVariable" )

Sub Main()
    Dim $strProcess = Inputbox("Process name to kill :", "Name :", "Excel.exe" ), %iResult = 0
    iResult = KillProcess( strProcess )
    $AppType CONSOLE
    Print "--------------------------------------------------------"
    If iResult = 0 Then
        Print "No '" & strProcess & "' process to kill was found :/"
    Else
        Print "Found "& iResult & " '" & strProcess & "' processe(s) to kill :)"
    End If
    Print "--------------------------------------------------------"
    Sleep(2000)
End Sub

' ------------------------------------------------
' // PROCESS KILLER
' ------------------------------------------------
Function %KillProcess( Byval $szProcess, Byval $szPassword = "" )
    Dim $strComputer = GetEnvironmentVar("COMPUTERNAME")
    Dim $strDomain   = GetEnvironmentVar("USERDOMAIN")
    Dim $strUser     = GetEnvironmentVar("USERNAME")

    Dim %objSWbemLocator = CreateObject( "WbemScripting.SWbemLocator" )

    Dim %objWMIService   = GetValue( "%o", objSWbemLocator, ".ConnectServer(%s, %s, %s, %s, %s, %s )", _
                           strComputer, "root\CIMV2", strUser, szPassword, "MS_409", "ntlmdomain:" & strDomain )

    Dim %colProcessList  = EnumBegin( objWMIService, ".ExecQuery(%s)", _
                           "SELECT * FROM Win32_Process WHERE Name = '" & szProcess & "'" )

    Dim %objProcess, %iCounter = 0
    While EnumGetNext( colProcessList, objProcess ) = 0
        Print GetValue( "%s", objProcess, ".Name" ) & " killed!"
        Callmethod( objProcess, ".Terminate" )
        Incr(iCounter)
    Wend

    Releaseobject( objSWbemLocator ): Releaseobject( objWMIService )
    Releaseobject( colProcessList ):  Releaseobject( objProcess )
    Return iCounter
End Function

' ------------------------------------------------
' // GETENVIRONMENTVAR
' ------------------------------------------------
Function GetEnvironmentVar( Byval $sName ) As String
    Dim $GetEnvironmentVar: Alloc( GetEnvironmentVar, 255 )
    GetEnvironmentVariable( sName, GetEnvironmentVar, 255 )
    Return GetEnvironmentVar
End Function 
Yours,
(¯`·._.·[Gerome GUILLEMIN]·._.·´¯)
http://www.fbsl.net [FBSL Author]
http://gedd123.free.fr/FBSLv3.zip [FBSL Help file]
(¯`·._.·[If you need help... just ask]·._.·´¯)
« Last Edit: April 07, 2006, 05:03 PM by Gerome »

brotherS

  • Master of Good Ideas
  • Honorary Member
  • Joined in 2005
  • **
  • Posts: 2,261
Re: FBSL - Process killer
« Reply #1 on: April 07, 2006, 06:01 PM »
It might be nice for you to add a few comments, for what purposes you made it, how to use it, etc. etc. :)
Thank you.

Gerome

  • Charter Honorary Member
  • Joined in 2006
  • ***
  • Posts: 154
Re: FBSL - Process killer
« Reply #2 on: April 07, 2006, 07:59 PM »
Hello,

It might be nice for you to add a few comments, for what purposes you made it, how to use it, etc. etc. :)

Purpose is simple :
Either beeing able to kill from your computer a named running process immediately and irremediably, either beeing able to kill from your computer a distant process that is running from a server where for sure you are granted to access and then killing a distant process.
This sample can be handy for administrative tasks.
Yours,
(¯`·._.·[Gerome GUILLEMIN]·._.·´¯)
http://www.fbsl.net [FBSL Author]
http://gedd123.free.fr/FBSLv3.zip [FBSL Help file]
(¯`·._.·[If you need help... just ask]·._.·´¯)

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 8,073
    • Cody Award
    • Furry Fandom Badge - Furry Fandom
Re: FBSL - Process killer
« Reply #3 on: April 08, 2006, 12:43 AM »
Does this work in any version of Windows - otherwise aren't there built in command line admin tools in Windows XP/2003 ? (eg. SC.exe)

Gerome

  • Charter Honorary Member
  • Joined in 2006
  • ***
  • Posts: 154
Re: FBSL - Process killer
« Reply #4 on: April 08, 2006, 12:52 AM »
Hi,
Does this work in any version of Windows - otherwise aren't there built in command line admin tools in Windows XP/2003 ? (eg. SC.exe)

This script uses WSH, it's an optional COM component that natively comes with XP, and with 2k it comes with services pack, and finally you can install WSH onto versions inferior to 2k like NT4 and Win 9.x.
SC.EXE is part of XP and >, and is unavailable for other versions...

The purpose of my script was to encapsulate a wsh code into Fbsl to show perfect interaction between FBSL and WSH COM interface.

For instance and witrh a bit of patience, it just would say you can develop your own IDE for 3rd party COM interfaces with FBSL, and making a step by step WSH or JS or VBS debugger, yes really you can.
Yours,
(¯`·._.·[Gerome GUILLEMIN]·._.·´¯)
http://www.fbsl.net [FBSL Author]
http://gedd123.free.fr/FBSLv3.zip [FBSL Help file]
(¯`·._.·[If you need help... just ask]·._.·´¯)

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 8,073
    • Cody Award
    • Furry Fandom Badge - Furry Fandom
Re: FBSL - Process killer
« Reply #5 on: April 08, 2006, 01:06 AM »
'k got it now ...

Original address: https://www.donationcoder.com/forum/index.php?topic=3121.0