?
Solved

vb script to stop other scripts runnning

Posted on 2011-09-26
2
Medium Priority
?
572 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Introduction to Processes
Starting up a Project

764 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