schedule the stop of a program

  • Thread starter Thread starter Doraj
  • Start date Start date
D

Doraj

I want to stop a program with a scheduled task.
The problem is that the program can't be stopped with a script like
"MyProg -stop".

Is there a way to stop it only with his name in a scheduled task (my
problem is that I don't know any particular command line for it)

Thanks a lot

Doraj
 
You can probably do this with VBScript if you know the file name of the program that is running (press Ctrl+Shift+Esc, select the Processes tab and check the list to help find out what the executable name is). Copy the following lines to Notepad, edit the second line to the program you want to stop, then save as KillProcess.vbs or other descriptive name with .vbs file extension. Test it manually by double clicking the script file you just saved. If it works, create a new task to point to the script file.

'edit the following program name to be killed
sProcessItemName = "notepad.exe"

For each ProcessItem in GetObject("winmgmts:{impersonationLevel=" & _
"impersonate,(Debug)}").InstancesOf("win32_process")
If ProcessItem.Name = sProcessItemName Then
ProcessItem.Terminate ProcessItem.ProcessID
End If
Next

Be careful what processes you kill, some might cause serious problems with the current Windows session when killed.

--

Bill James
Microsoft MVP - Shell/User

Win9x VBScript Utilities » www.billsway.com/vbspage/
Windows Tweaks & Tips » www.billsway.com/notes_public/
 
Bill said:
You can probably do this with VBScript if you know the file name of the program that is running (press Ctrl+Shift+Esc, select the Processes tab and check the list to help find out what the executable name is). Copy the following lines to Notepad, edit the second line to the program you want to stop, then save as KillProcess.vbs or other descriptive name with .vbs file extension. Test it manually by double clicking the script file you just saved. If it works, create a new task to point to the script file.

'edit the following program name to be killed
sProcessItemName = "notepad.exe"

For each ProcessItem in GetObject("winmgmts:{impersonationLevel=" & _
"impersonate,(Debug)}").InstancesOf("win32_process")
If ProcessItem.Name = sProcessItemName Then
ProcessItem.Terminate ProcessItem.ProcessID
End If
Next

Be careful what processes you kill, some might cause serious problems with the current Windows session when killed.

It works fine, thanks a lot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top