Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8223435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:41:50+00:00 2026-06-07T14:41:50+00:00

I am attempting to create a VBscript that will kill a Windows process that

  • 0

I am attempting to create a VBscript that will kill a Windows process that is passed in as a parameter (argument). I have the following code and believe the problem to be at either line 8, 18, or 24 but am not sure what the problem is. When I replace that code with notepad.exe instead of the variable, it works. Any help would be great. Thanks.

Dim prcid
Dim check
Dim Inp
Set Inp = WScript.Arguments
check=0
Set objService = GetObject("winmgmts:")

For Each Process In objService.InstancesOf("Win32_process")
  If process.name= "Inp" Then
    prcid=process.processid
    check=1
    Exit For
  End If
Next

If check =0 Then
  WScript.Quit [ExitCode]
End if

For Each process In objService.InstancesOf("Win32_process")
  If process.name= "Inp" Then
    If process.processid=prcid Then
        strComputer = "."
        Set objWMIService = GetObject("winmgmts:" _ 
          & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
        Set colProcessList = objWMIService.ExecQuery _
          ("SELECT * FROM Win32_Process WHERE Name = 'Inp'")
        For Each objProcess in colProcessList
            objProcess.Terminate()
        Next
    End If

    Exit For
  End If
Next
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:41:52+00:00Added an answer on June 7, 2026 at 2:41 pm

    You are using a variable as a literal:
    1. process.name= "Inp" should be process.name = Inp (twice)
    2. "SELECT * FROM Win32_Process WHERE Name = 'Inp'" should be "SELECT * FROM Win32_Process WHERE Name = '" & Inp & "'"

    And you are using the WScript.Arguments object incorrect: to get the first argument from the command line, use WScript.Arguments(0)

    Disclaimer: I did not test your code with these enhancements, I just spotted these errors on first sight. There could be more lurking inside.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to create a CustomControl which will have various properties affected by an
I am attempting to create an inbound Mule endpoint that will receive Syslog messages
So I am attempting to create a search field that will filter contacts on
I'm attempting to create an xquery expression that will return selected nodes but will
I'm attempting to create a table for monitoring purposes using the following script: $w3wppriv
I am attempting to create a report, utilizing a matrix, that only displays columns
I'm attempting to create a single Controller class to handle all foreseeable surveys that
I'm attempting to create a Parcelable class in Android so that I can pass
I am attempting to create the following class name signature: public class MyClass<T> where
i'm attempting to create an header which is divided into 3 divs they will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.