Solved

vb script to stop other scripts runnning

Posted on 2011-09-26
2
567 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 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Simple Linear Regression

705 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