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 9135101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:46:51+00:00 2026-06-17T08:46:51+00:00

I am new to vbs but have done programming in c, c++ n java.

  • 0

I am new to vbs but have done programming in c, c++ n java. I tried searching over the internet but I still cant find where am i wrong . I am making a script to kill a process named rundll if it exceeds 20% cpu usage.

Option Explicit
DIM MyPID(5), objProcess, objItems, objitem
DIM XX, I
XX = -1
dim objService
set objService = getobject("winmgmts:")
dim Process
for each Process in objService.InstancesOf("Win32_process")
if Process.Name = "rundll32.exe" Then XX = XX + 1
if Process.Name = "rundll32.exe" Then MyPID(XX) = Process.processid
Next

For I = 0 To 5
Set objProcess = GetObject("winmgmts:{impersonationLevel=impersonate}//localhost")
Set objItems = objProcess.ExecQuery("Select PercentProcessorTime from Win32_PerfFormattedData_PerfProc_Process where IDProcess=" &MyPID(I)& "")
if (IsNull(objItems)) Then
    Wscript.Echo "No process found"
    Exit For
End if
for each objItem in objItems
    if objItems = Null Then
    Wscript.Echo "No process found"
    elseif objItem>20 Then Wscript.Echo "Criminal process found :" & MyPID(I) & " = " & objItem.PercentProcessorTime
    End if
NEXT

NEXT

If the script doesnt find the process it should print no process found ,instead of a complicated null alert that i am getting now

Any help would be appreciated and so wud be suggestions

  • 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-17T08:46:52+00:00Added an answer on June 17, 2026 at 8:46 am

    Instead of enumerating PercentProcessorTime for particular PIDs try enumerating processes that exceed the threshold and terminate them if their name matches the criteria:

    Set wmi = GetObject("winmgmts://./root/cimv2")
    
    perfQuery = "SELECT * FROM Win32_PerfFormattedData_PerfProc_Process " & _
                "WHERE PercentProcessorTime >= 20"
    For Each p In wmi.ExecQuery(perfQuery)
      pidQuery = "SELECT * FROM Win32_Process WHERE ProcessId = " & p.IDProcess
      For Each p1 In wmi.ExecQuery(pidQuery)
        If p1.Name = "rundll32.exe" Then p1.Terminate
      Next
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am absolutely new to VB.NET, i've done some vbS a long time ago.
Have a question about VBS: How can i start a new window (e.g. of
Here I have a small VBS script that helps me append a new line
I tried installing my old ASPImage from server Objects in my new server, but
I am new to vbs and have a question. I have a js file
New to PHP and MySQL, have heard amazing things about this website from Leo
New developer here,Im using the Custom Image Picker by ray wenderlich. But what I
I have vbs script and that creates folder, make archive and copy to that
I have developed a exe of my Java application, and run it from a
I have this logic programming software that can output results in a text file

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.