Solved

vb script to stop other scripts runnning

Posted on 2011-09-26
2
565 Views
Last Modified: 2012-05-12
Hi,

i have a script that runs and what it does it starts a few different scripts sequentially.

On Error Resume Next
dim WshShell

set WshShell = CreateObject("WScript.Shell")


WshShell.Run "wscript.exe UTVCopyfilesfromserver.vbs", 2, FALSE
WScript.Sleep 3000
WshShell.Run "wscript.exe irnCopyfilesfromserver.vbs", 2, FALSE
WScript.Sleep 3000
WshShell.Run "wscript.exe utvnewsaudioconversion.vbs", 2, FALSE
WScript.Sleep 3000
WshShell.Run "wscript.exe irnnewsaudioconversion.vbs", 2, FALSE
WScript.Sleep 3000
WshShell.Run "wscript.exe UTVscriptexttonews.vbs", 2, FALSE
WScript.sleep 3000
WshShell.Run "wscript.exe irnscriptexttonews.vbs", 2, FALSE
WScript.Sleep 3000

WshShell.Run "cmd.exe /c copytoirnboxirntxt.bat", 2, FALSE
WshShell.Run "cmd.exe /c copytoirnboxutvaudio.bat", 2, FALSE
WshShell.Run "cmd.exe /c copytoirnboxutvtext.bat", 2, FALSE

I was wondering is there a script i could get that would stop the scripts from running at a certain time?

Thank you so much
0
Comment
Question by:jonathanduane2010
2 Comments
 
LVL 9

Expert Comment

by:raysonlee
ID: 36598040
You can use the timer() function - number of seconds after 12:00AM to determine whether the script should run at a specific period.
To terminate a running process, refer to sample in http://www.computerperformance.co.uk/vbscript/wmi_process_stop.htm
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 250 total points
ID: 36598548
Hi, this script should work, by looking at the commandline parameter of each process running, and terminate it if there's a match.

Just FYI too, your scripts don't technically run sequentially, they are more in parallel, since you're not waiting for the task to finish before executing the next one, because you have False set as the last parameter for each Run command.

Regards,

Rob.
On Error Resume Next

arrTasks = Array( _
	"UTVCopyfilesfromserver.vbs", _
	"irnCopyfilesfromserver.vbs", _
	"utvnewsaudioconversion.vbs", _
	"irnnewsaudioconversion.vbs", _
	"UTVscriptexttonews.vbs", _
	"irnscriptexttonews.vbs", _
	"copytoirnboxirntxt.bat", _
	"copytoirnboxutvaudio.bat", _
	"copytoirnboxutvtext.bat" _
	)

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
For Each strCommand In arrTasks
	Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE CommandLine LIKE '%" & strCommand & "%'", "WQL", _
	                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)
	For Each objItem In colItems
		objItem.Terminate
	Next
Next

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question