Kill a .exe

Author Message
n2clarkster

  • Total Posts : 12
  • Scores: 0
  • Reward points : 0
  • Joined: 9/12/2009
  • Status: offline
Kill a .exe Saturday, September 12, 2009 7:32 AM (permalink)
0
Below is a simple .vbs I use to kill processes.
 
'n2clarkster2yahoo.com  www.vbsbytes.com
Set WshShell = WScript.CreateObject("WScript.Shell")
Q = Inputbox ( "What is the name of the .exe you want me to kill??? Enter it as name.exe" )
MsgBox "The following file will be killed: "& Q
WshShell.Run "taskkill /F /IM " & Q
 
#1
    meanhacker

    • Total Posts : 4
    • Scores: 0
    • Reward points : 0
    • Joined: 9/16/2009
    • Status: offline
    Re:Kill a .exe Wednesday, September 16, 2009 7:02 PM (permalink)
    0
    doesn't work - says:

    Line 5
    Char 1
    Error: The system cannot find the file specified
    Code 80070002
     
    #2
      mbouchard

      • Total Posts : 2110
      • Scores: 29
      • Reward points : 0
      • Joined: 5/15/2003
      • Location: USA
      • Status: offline
      Re:Kill a .exe Wednesday, September 16, 2009 11:56 PM (permalink)
      0
      Worked for me, do you have Taskkill in your path?  Not sure which OS's it is included with.
      Mike

      For useful Scripting links see the Read Me First stickey!

      Always remember Search is your friend.
       
      #3
        andreas

        • Total Posts : 15
        • Scores: 0
        • Reward points : 0
        • Joined: 4/12/2007
        • Location: Sweden / Kalmar
        • Status: offline
        Re:Kill a .exe Tuesday, September 22, 2009 6:23 PM (permalink)
        0
        Posting a small example thats part of my Virus/Malware search&destroy script that handles viruses not taken care of by the Antivirus software
         
               '==========================================================================
             '
             ' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 2009
             '
             ' NAME: 
             '
             ' AUTHOR: Andreas Borén, Most of the code ripped from the scriptinguys over at MS$ 
             ' DATE  : 2009-09-23
             '
             ' COMMENT: Demonstrates a function wich kills all instances of a given process.
             '
             '==========================================================================
             'Putting an Inputbox as a reply to this topic, but easy enough to handle with args or whatever you need
             Dim WhatToKill, Result
             WhatToKill = Inputbox ( "What is the name of the PROCESS you want me to kill??? process.name" )
             'To run script with argument, uncomment the following rows of code & comment out the InputBox row above
             'Set objArgs = WScript.Arguments
             'WhatToKill = objArgs(0)
             Result = KillMe (WhatToKill)
             WScript.Echo Result
             Function KillMe(procID)
             Dim objWMIService, objProcess, colProcess
             Dim strComputer, strProcessKill
             Dim iePID
             dim wshShell
             Set wshShell = WScript.CreateObject("WScript.Shell")
             strComputer = "."'works on remote computers to, you got to be admin tho ;)
             Set iePID = CreateObject("Scripting.Dictionary")
             On Error Resume Next
             Set objWMIService = GetObject("winmgmts:" _
             & "{impersonationLevel=impersonate}!\\" _
             & strComputer & "\root\cimv2")
             Set iePID = objWMIService.ExecQuery _
             ("Select * from Win32_Process Where Name = '" & procID & "'" )
             If iePID > 0 Then'If process exists, kill it. Recheck for the process & kill every single one until there are no more.
             For Each objProcess in iePID
             objProcess.Terminate()
             Next
             End If
             KillMe = "All instances of '" & procID & "' has been terminated."
             End Function     

        --------
        /Andreas
         
        #4
          n2clarkster

          • Total Posts : 12
          • Scores: 0
          • Reward points : 0
          • Joined: 9/12/2009
          • Status: offline
          Re:Kill a .exe Wednesday, September 23, 2009 1:00 PM (permalink)
          0
          'Below is an updated version of the same simple .vbs to kill processes. I added a Message Box Title and exit box to dress it up a little.
          'n2clarkster@yahoo.com  www.vbsbytes.com
          'tested with XP and Vista
          Set WshShell = WScript.CreateObject("WScript.Shell")
          Dim MsgBox2,Q,message
          MSGBOXTitle ="Taskkill Tool 2009"
          Q = InputBox("What is the name of the .exe you want me to kill???  Enter it as name.exe" , MSGBOXTitle)
          MsgBox "The following file will be killed: " & Q
          WshShell.Run "taskkill /F /IM " & Q
          message = "Thanks for using the tool to kill processes!"
          MsgBox2 = MsgBox(message,vbExclamation,MSGBOXTitle)
          'Below is the original.
          'n2clarkster2yahoo.com  www.vbsbytes.com
          'Set WshShell = WScript.CreateObject("WScript.Shell")
          'Q = Inputbox ( "What is the name of the .exe you want me to kill??? Enter it as name.exe" )
          'MsgBox "The following file will be killed: "& Q
          'WshShell.Run "taskkill /F /IM " & Q
           
           
          #5
            ZooBeast

            • Total Posts : 8
            • Scores: 0
            • Reward points : 0
            • Joined: 9/17/2009
            • Status: offline
            Re:Kill a .exe Saturday, October 17, 2009 8:35 AM (permalink)
            0
            Replace
            WshShell.Run "taskkill /F /IM " & Q   

            With
            strCommand = "taskkill /F /IM " & Q   
             WshShell.Run strCommand, 0, TRUE 

            If You Want To Stop The Command Window From Opening, When It Runs taskkill.exe
            You Could Do This Many Ways The Important Bit Is The
             0, TRUE 




            <message edited by ZooBeast on Saturday, October 17, 2009 9:04 AM>
             
            #6
              n2clarkster

              • Total Posts : 12
              • Scores: 0
              • Reward points : 0
              • Joined: 9/12/2009
              • Status: offline
              Re:Kill a .exe Sunday, October 25, 2009 5:47 AM (permalink)
              0
              Thanks I like the suggested modifications!
               
              #7

                Online Bookmarks Sharing: Share/Bookmark

                Jump to:

                Current active users

                There are 0 members and 1 guests.

                Icon Legend and Permission

                • New Messages
                • No New Messages
                • Hot Topic w/ New Messages
                • Hot Topic w/o New Messages
                • Locked w/ New Messages
                • Locked w/o New Messages
                • Read Message
                • Post New Thread
                • Reply to message
                • Post New Poll
                • Submit Vote
                • Post reward post
                • Delete my own posts
                • Delete my own threads
                • Rate post

                2000-2012 ASPPlayground.NET Forum Version 3.9