Solved

vb script to stop other scripts runnning

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Apps blocked by Java 9 84
Remove Password Protection from pdf (with password) using an command line executable 5 54
Batch file or script with password 22 45
Help Required 2 34
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

825 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