Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / MS JScript / July 2008



Tip: Looking for answers? Try searching our database.

show processes?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tomasz Chmielewski - 03 Jul 2008 12:23 GMT
How can I check if a process with a given name is running?

It seems I have to use GetProcessesByName:

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.getprocessesb
yname(VS.71).aspx


unfortunately, "No example is available for JScript".

What would an example look like if I wanted to check if notepad.exe is
running?

Signature

Tomasz Chmielewski
http://wpkg.org

Anthony Jones - 03 Jul 2008 13:29 GMT
> How can I check if a process with a given name is running?
>
> It seems I have to use GetProcessesByName:

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.getprocessesb
yname(VS.71).aspx


> unfortunately, "No example is available for JScript".
>
> What would an example look like if I wanted to check if notepad.exe is
> running?

The C# example is going to be the closest.  Slap that into JScript.NET and
see what breaks.  I suspect you'll only need to tidy up a few syntatical
things and you'll be there.

If you mean JScript in the standard scripty sense then whilst a port may be
possible that make use of the System.Diagnostics.Process object there will
be ugly hoops to jump through.

In this case you'll be better off finding a VBScript example of doing this
with WMI or ADSI then porting to JScript.

Signature

Anthony Jones - MVP ASP/ASP.NET

Tomasz Chmielewski - 03 Jul 2008 14:56 GMT
Anthony Jones schrieb:
>> How can I check if a process with a given name is running?
>>
[quoted text clipped - 17 lines]
> In this case you'll be better off finding a VBScript example of doing this
> with WMI or ADSI then porting to JScript.

Here is one which enumerates all processes in JScript - as found on
Microsoft Platform SDK for Windows Server 2003 R2
(5.2.3790.2075.51.PlatformSDK_Svr2003R2_rtm.img) in Process.Js:

try
{
        var e = new Enumerator
(GetObject("winmgmts:").InstancesOf("Win32_process"));

        for (;!e.atEnd();e.moveNext())
        {
                var p = e.item ();
                WScript.Echo (p.Name, p.Handle);
        }
}
catch (e)
{
        WScript.Echo ("Error in script: " + e);
}

Signature

Tomasz Chmielewski
http://wpkg.org

Tomasz Chmielewski - 03 Jul 2008 21:29 GMT
Tomasz Chmielewski schrieb:

(...)

> Here is one which enumerates all processes in JScript - as found on
> Microsoft Platform SDK for Windows Server 2003 R2
[quoted text clipped - 15 lines]
>         WScript.Echo ("Error in script: " + e);
> }

And for the reference, here is a sample script I wrote which checks if
any given processes are running:

http://wpkg.org/Script_for_checking_if_a_process_is_already_running

Signature

Tomasz Chmielewski

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.