end task Outlook.exe from command line? 
Author Message
 end task Outlook.exe from command line?

How do you stop a program or end task from the command
line. For example, I have a small batch to clean out a lot
of temporary files, but many times the files are in use by
various programs, so I would like to stop those programs
so that I can delete these files. Starting them back up is
easy. I found just dragging shortcuts to the programs,
then looking at the properties of the shortcut gave me a
copy-and-pasteable path to the exexcutable I need. But I
do not know how to stop the program from the command line.
Help please.


Wed, 27 Jul 2005 06:43:19 GMT  
 end task Outlook.exe from command line?
You didn't say what operating system(s) you're dealing with. The Windows NT
and 2000 Resource Kits come with a kill utility, and there are many freeware
equivalents floating around (often packaged with collections of Unix
utilities ported to Windows). Some implementations might force you to kill
by process ID number, which wouldn't be as convenient as name for your
situation.

I'm somewhat fond of http://www.prcview.com/ not just because it's free but
also because it supports all Win32 operating systems and provides both a
command-line version (pv.exe) and a GUI version. It can kill by process
name.

Since you're in the WSH newsgroup, though, you might be interested in a true
WSH solution. One way is to use WMI. See an example in the article at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncl...
and another which kills Excel at
http://businessintelligence.ittoolbox.com/code/d.asp?d=1686&a=s

Another way is to use a COM component. One such COM component can be found
in the Wrox book on WSH: http://www.wrox.com/books/1861002653.htm.

By the way, if you've been killing Outlook manually, you may have already
run into this, but you sometimes need to kill mapisp32.exe after you kill
Outlook before you can cleanly restart Outlook.



Wed, 27 Jul 2005 10:00:45 GMT  
 end task Outlook.exe from command line?

Quote:

> How do you stop a program or end task from the command
> line. For example, I have a small batch to clean out a lot
> of temporary files, but many times the files are in use by
> various programs, so I would like to stop those programs
> so that I can delete these files. Starting them back up is
> easy. I found just dragging shortcuts to the programs,
> then looking at the properties of the shortcut gave me a
> copy-and-pasteable path to the exexcutable I need. But I
> do not know how to stop the program from the command line.
> Help please.

/*////////////////////////////////////////////////////////////////////
     FileName:   KillProc.js

     Copy this script to dir in path (C:\, C:\Winnt or C:\Windows,...)
     From command line:
          C:\>KillProc notepad.exe

     Sript assumes:
         - WMI (WinXP, Win2K or WinNT with WMI core),
         - User running it must have administrative privileges.
*/////////////////////////////////////////////////////////////////////
var oShell = new ActiveXObject("Wscript.Shell");
var oArgs = WScript.Arguments;
var sArgsAry = new Array();
var sArgsLine = "";

//  --- Make sure there are comand line parameters:
if (oArgs.length==0) {
     sMsg = "Usage: \n\tC:\\>KillProc notepad.exe [winword.exe ...]"
     WScript.Echo(sMsg);
     WScript.Quit();

Quote:
}

//  --- Collect script arguments (if any):
for (var i=0; i<oArgs.length ; i++) {
     //  Collect passed arguments
     sArgsLine += "\"" + oArgs(i) + "\" ";
     sArgsAry[sArgsAry.length] = oArgs(i)

Quote:
}

//  --- Ensure that CScript.exe is the host:
if (!isCScript()) {
     var sMsg = "CScript.exe must be used to run this script.\n\n";
     sMsg += "To set CScript as the default host:\n\n";
     sMsg += "C:\\>WScript //H:CScript";
     WScript.Echo(sMsg);
     WScript.Quit();

Quote:
}

// --- Kill process(es):
for (var i=0; i<sArgsAry.length ; i++) {
     WScript.Echo("Killing (if any): " + sArgsAry[i]);
     KillProcess(sArgsAry[i]);

Quote:
}

function KillProcess(sProg) {
     try { var oWMI = GetObject("winmgmts:{impersonationLevel=impersonate,(Debug)}");
     } catch(e) { return; }
     var sQuery = "select * from win32_process where name='" + sProg + "'";
     try { var oEnm = new Enumerator(oWMI.execquery(sQuery));
     } catch(e) { return; }

     for (;!oEnm.atEnd();oEnm.moveNext()) { oEnm.item().terminate(); }

Quote:
}

function isCScript() { return (/cscript.exe$/i).test(WScript.FullName); }

// Branimir



Wed, 27 Jul 2005 11:21:37 GMT  
 end task Outlook.exe from command line?
This is what I do,  using WMI and VBScript, when I auto-backup my Outlook
mail every morning:
set wmi = getobject("winmgmts:")
wql = "select * from Win32_Process " & " where name='outlook.exe'"
set results = wmi.execquery(wql)
for each app in results
  app.terminate
next

wscript.sleep 10000


:
: How do you stop a program or end task from the command
: line. For example, I have a small batch to clean out a lot
: of temporary files, but many times the files are in use by
: various programs, so I would like to stop those programs
: so that I can delete these files. Starting them back up is
: easy. I found just dragging shortcuts to the programs,
: then looking at the properties of the shortcut gave me a
: copy-and-pasteable path to the exexcutable I need. But I
: do not know how to stop the program from the command line.
: Help please.



Wed, 27 Jul 2005 23:06:43 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Different line ends/segment ends on dashed line?

2. Different line ends/segment ends on dashed line?

3. Task Scheduler ignores command-line parameter

4. Exe ASP from command line

5. getting output of command line exe

6. Trouble using blat.exe or command-line mailer in a vbscript

7. Exe ASP from command line

8. getting output of command line exe

9. Passing values into and out of Command Line application *and* command line prompt in vbscript

10. Scripting command line applications & Command Line Prompting

11. Detecting end of line and end of file while using the .Read() method

12. Outlook command-line parameters.

 

 
Powered by phpBB® Forum Software