PROCESS QUESTION - t.py [01/01]

Pat Knight p.knight at ktgroup.co.uk
Thu Jul 6 04:54:17 EDT 2000


In article <3961D1D2.9C66B425 at sicon.net>, sergio <smoriano at sicon.net> wrote:
>  Hi all, I'm working in NT SERVER 4.0
>
>How can i search the id of a process running, searching it by the name?
>

You need to get Mark Hammond's Pythonwin package (version 129 if you're 
running Python 1.52).

Use the win32pdh package to enumerate the processes on a system and then 
process the returned list. Attached is a function that doesn't quite do what 
you want. It tests to see if a process with a given id (and optionally name) 
is running. It should be easy to modify to get an id for a name.

Cheers,
        Pat

begin 644 t.py
M:6UP;W)T('=I;C,R<&1H#0II;7!O<G0@<WES#0H-"G1R>3H-"B`@("`C(%9E
M<G-I;VYS('!R:6]R('1O(#$R.2!D;VXG="!H879E($5N=6U/8FIE8W1S#0H@
M("`@=VEN,S)P9&@N16YU;4]B:F5C=',-"F5X8V5P=#H-"B`@("!P<FEN="`B
M=VEN,S)P9&@@;6]D=6QE(&1O97-N)W0@:&%V92!T:&4 at 16YU;4]B:F5C=',@
M05!)(@T*("`@('-Y<RYE>&ET*#$I#0H-"F1E9B!C:&5C:U]F;W)?<')O8V5S
M<R`H<&ED+"!E>&5C=71A8FQE(#T@)R<I. at T*("`@("<G)PT*("`@(%-E92!I
M9B!T:&4@<')O8V5S<R!I9&5N=&EF:65D(&)Y(")P:60B(&ES(')U;FYI;F<N
M($EF(&ET(&ES+"!O<'1I;VYA;&QY#0H@("`@=&5S="!T:&4 at 97AE8W5T86)L
M92!N86UE(&%S<V]C:6%T960@=VET:"!T:&4@<&ED('1O('-E92!I9B!I="!I
M<R!T:&4-"B`@("!S86UE(&%S(")E>&5C=71A8FQE(BX@(F5X96-U=&%B;&4B
M(&-A;B!B92!A('-T<FEN9R!O<B!S97%U96YC92!O9 at T*("`@('-T<FEN9W,N
M($EN('1H92!L871T97(@8V%S92P@=V4@=&5S="!I9B!T:&4@(G!I9"(@<')O
M8V5S<R!H87, at 86YY(&]F#0H@("`@=&AE(&YA;65S(&EN('1H92!L:7-T+B!.
M;W1E('1H870@=V4 at 8V%N;F]T(&%L=V%Y<R!K;F]W(&EF("Y%6$4@:7,-"B`@
M("!O;B!T:&4 at 96YD(&]F('1H92!N86UE<R!W92!P<F]C97-S+"!S;R!W92!A
M;'=A>7,@=')A;G-F;W)M(&%L;`T*("`@(&5X96-U=&%B;&4@;F%M97,@=&\@
M=7!P97)C87-E('=I=&@@82`N15A%(&]N('1H92!E;F0 at 8F5F;W)E#0H@("`@
M8V]M<&%R:6YG+ at T*("`@("<G)PT*("`@(", at 4$1((&1O97-N)W0@<V5E;2!T
M;R!U<&1A=&4@=&AE(&QI<W0@;V8@<')O8V5S<V5S('5N;&5S<R!W92!R969R
M97-H#0H@("`@(R!T:&4 at 8V]M<&QE=&4@;&ES="!O9B!P97)F;W)M86YC92!O
M8FIE8W1S(2$-"B`@("!W:6XS,G!D:"Y%;G5M3V)J96-T<R`H3F]N92P at 3F]N
M92P@=VEN,S)P9&@N4$521E]$151!24Q?5TE:05)$+#$I#0H@("`@<')O8U]L
M:7-T(#T@=VEN,S)P9&@N16YU;4]B:F5C=$ET96US("@-"B`@("`@("`@3F]N
M92P at 3F]N92P@(E!R;V-E<W,B+"!W:6XS,G!D:"Y015)&7T1%5$%)3%]725I!
M4D0L(#`I6S%=#0H@("`@8VQI<W0@/2!;70T*("`@(&EN<W1A;F-E<R`](%M=
M#0H@("`@:68 at 97AE8W5T86)L92!A;F0@:7-I;G-T86YC92AE>&5C=71A8FQE
M+'1Y<&5S+E-T<FEN9U1Y<&4I. at T*("`@("`@("!E>&5C=71A8FQE(#T@*&5X
M96-U=&%B;&4L*0T*#0H@("`@(R!)9B!T:&5R92!A<F4@;75L=&EP;&4@:6YS
M=&%N8V5S(&]F(&$@<')O8V5S<R!R=6YN:6YG+"!W92!N965D#0H@("`@(R!T
M;R!D:7-T:6YG=6ES:"!T:&5M('5S:6YG(&-O=6YT97(@<&%T:"!N86UE<R!O
M9B!T:&4 at 9F]R;0T*("`@(", at 7%Q0<F]C97-S*#QN86UE/B,\;G5M8F5R/BDN
M(%1H92!F;VQL;W=I;F<@;F5S=&5D(&QO;W!S(&-H96-K#0H@("`@(R!T:&4@
M<&]S<VEB;'D at 9'5P;&EC871E9"!I;G-T86YC97,@<F5T=7)N960 at 8GD@16YU
M;4]B:F5C=$ET96US#0H@("`@(R!A;F0@='5R;B!T:&5M(&EN=&\@=6YI<75E
M('!R;V-E<W,@:6YS=&%N8V4@;F%M97,N#0H@("`@9F]R('`@:6X@<')O8U]L
M:7-T. at T*("`@("`@("!I(#T@,`T*("`@("`@("!W:&EL92`Q. at T*("`@("`@
M("`@("`@<&YA;64@/2`B)7,C)60B("4@*'`L:2D-"B`@("`@("`@("`@(&EF
M('!N86UE(&EN(&EN<W1A;F-E<SH-"B`@("`@("`@("`@("`@("!I(#T@:2`K
M(#$-"B`@("`@("`@("`@(&5L<V4Z#0H@("`@("`@("`@("`@("`@:6YS=&%N
M8V5S+F%P<&5N9"AP;F%M92D-"B`@("`@("`@("`@("`@("!B<F5A:PT*#0H@
M("`@<75E<GD@/2!W:6XS,G!D:"Y/<&5N475E<GDH*0T*("`@('1R>3H-"B`@
M("`@("`@9F]R('`@:6X@:6YS=&%N8V5S. at T*("`@("`@("`@("`@8V]U;G1E
M<E]P871H(#T@(EQ<4')O8V5S<R at E<RE<7$E$(%!R;V-E<W,B("4@<`T*("`@
M("`@("`@("`@8VQI<W0N87!P96YD*"AP+'=I;C,R<&1H+D%D9$-O=6YT97(H
M<75E<GDL(&-O=6YT97)?<&%T:"DI*0T*("`@("`@("!W:6XS,G!D:"Y#;VQL
M96-T475E<GE$871A("AQ=65R>2D-"B`@("`@("`@9F]R('`L8R!I;B!C;&ES
M=#H-"B`@("`@("`@("`@('1R>3H-"B`@("`@("`@("`@("`@("!O=&AE<B`]
M('=I;C,R<&1H+D=E=$9O<FUA='1E9$-O=6YT97)686QU92 at -"B`@("`@("`@
M("`@("`@("`@("`@8RQW:6XS,G!D:"Y01$A?1DU47TQ/3D<I#0H@("`@("`@
M("`@("!E>&-E<'0Z("`@("`@("`@("`@("`@("`@("`@(R!I9B!A('!R;V-E
M<W,@:&%S(&1I<V%P<&5A<F5D#0H@("`@("`@("`@("`@("`@<')I;G0@(D5X
M8V5P=&EO;B!F;W(@)7,B("4@<`T*("`@("`@("`@("`@("`@(&-O;G1I;G5E
M("`@("`@("`@("`@("`@(",@=V4 at 9V5T(&%N(&5X8V5P=&EO;@T*#0H@("`@
M("`@("`@("!O=&AE<B`](&]T:&5R6S%=("`@("`@("`@("`@(R!E>'1R86-T
M('1H92!P<F]C97-S(&ED#0H@("`@("`@("`@("!I9B!P:60@/3T@;W1H97(Z
M#0H@("`@("`@("`@("`@("`@:68@;F]T(&5X96-U=&%B;&4Z#0H@("`@("`@
M("`@("`@("`@("`@(')E='5R;B`Q("`@("`@("`@("`@(R`B<&ED(B!I<R!R
M=6YN:6YG#0H@("`@("`@("`@("`@("`@96QS93H-"B`@("`@("`@("`@("`@
M("`@("`@<&ED7VYA;64@/2!S=')I;F<N=7!P97(H<W1R:6YG+G-P;&ET*'`L
M)R,G+#$I6S!=*0T*("`@("`@("`@("`@("`@("`@("!I9B!P:61?;F%M92!;
M+30Z72`A/2`G+D5812<Z#0H@("`@("`@("`@("`@("`@("`@("`@("!P:61?
M;F%M92`]('!I9%]N86UE("L@)RY%6$4G#0H@("`@("`@("`@("`@("`@("`@
M(')E='5R;B!P:61?;F%M92!I;B!E>&5C=71A8FQE#0H@("`@("`@(')E='5R
M;B`P#0H@("`@9FEN86QL>3H-"B`@("`@("`@=VEN,S)P9&@N0VQO<V51=65R
+>2`H<75E<GDI#0H`
`
end



More information about the Python-list mailing list