Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 02-03-2011, 02:29 AM   #1
Beta Member
 
Join Date: Jan 2011
Posts: 3
Default How can I eliminate the"OK" prompt from a VB Script?

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:
Code:
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.
__________________

steve.marks59 is offline   Reply With Quote
Old 02-03-2011, 03:13 AM   #2
Daemon Poster
 
Join Date: Jun 2004
Posts: 511
Send a message via AIM to Denthúl Send a message via MSN to Denthúl Send a message via Yahoo to Denthúl
Default Re: How can I eliminate the"OK" prompt from a VB Script?

Remove all the instances of WScript.Echo from the script. Out of interest, do you have any knowledge of VBScript at all?
__________________

Denthúl is offline   Reply With Quote
Old 02-03-2011, 03:13 AM   #3
Beta Member
 
Join Date: Jan 2011
Posts: 3
Default Re: How can I eliminate the"OK" prompt from a VB Script?

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.
steve.marks59 is offline   Reply With Quote
Old 02-04-2011, 08:59 AM   #4
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: How can I eliminate the"OK" prompt from a VB Script?

You can't delete the thread which is a good thing - even though your particular problem is solved, someone might come searching here for a solution to a similar issue and then have this resolved by this thread. If we just deleted all threads that were "solved", this site would become a far less useful resource!
__________________
Save the whales, feed the hungry, free the mallocs.
berry120 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 08:23 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0