Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

How can I eliminate the"OK" prompt from a VB Script?


  • Please log in to reply
1 reply to this topic

#1 steve.marks59

steve.marks59

  • Members
  • 11 posts
  • OFFLINE
  •  
  • Local time:12:38 AM

Posted 03 February 2011 - 02:33 AM

My OS is XP-Pro SP3

I use the VB Script shown below to quickly kill applications when I don't want them loading at startup. This VB Script seems to kill the applications much faster than running a batch file to start taskkill.exe. However I would rather not have to click the "OK" button prompted AFTER each application is terminated. Seems pointless anyway to be asked for an "OK" AFTER the application has been killed. Can this script be modified to eliminate the pointless prompts? I would not have ran the script in the first place if I did not want to kill the apps.

The popup window displays how many instances of the application it has killed and you have to click the "OK" button before the script will kill the next application or close.

This is the script:
strComputer = "."
strProcessToKill = "cmd.exe" 

Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" _ 
        & strComputer & "\root\cimv2") 

Set colProcess = objWMIService.ExecQuery _
        ("Select * from Win32_Process Where Name = '" & strProcessToKill & "'")

count = 0
For Each objProcess in colProcess
        objProcess.Terminate()
        count = count + 1
Next 


wscript.echo "Killed " & count & " instances of " & _
        strProcessToKill & "on " & strComputer


strComputer = "."
strProcessToKill = "firefox.exe" 

Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" _ 
        & strComputer & "\root\cimv2") 

Set colProcess = objWMIService.ExecQuery _
        ("Select * from Win32_Process Where Name = '" & strProcessToKill & "'")

count = 0
For Each objProcess in colProcess
        objProcess.Terminate()
        count = count + 1
Next 


wscript.echo "Killed " & count & " instances of " & _
        strProcessToKill & "on " & strComputer


strComputer = "."
strProcessToKill = "yahoomessenger.exe" 

Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" _ 
        & strComputer & "\root\cimv2") 

Set colProcess = objWMIService.ExecQuery _
        ("Select * from Win32_Process Where Name = '" & strProcessToKill & "'")

count = 0
For Each objProcess in colProcess
        objProcess.Terminate()
        count = count + 1
Next 


wscript.echo "Killed " & count & " instances of " & _
        strProcessToKill & "on " & strComputer



Thanks.

BC AdBot (Login to Remove)

 


#2 steve.marks59

steve.marks59
  • Topic Starter

  • Members
  • 11 posts
  • OFFLINE
  •  
  • Local time:12:38 AM

Posted 03 February 2011 - 03:14 AM

Posted Today, 12:07 AM
PLEASE DISREGARD THIS THREAD MY PROBLEM WAS SOLVED ELSEWHERE.
ALL I HAD TO DO WAS COMMENT OUT THE THREE PLACES THESE TWO LINES APPEAR"

wscript.echo "Killed " & count & " instances of " & _
strProcessToKill & "on " & strComputer



IF I KNEW HOW I WOULD HAVE DELETED THIS THREAD SO I WOULD NOT WASTE ANYONE'S TIME.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users