Page 1 of 1 1
Topic Options
#36306 - 2003-02-11 09:04 PM Checking for a running process, execute if not running
Diane Offline
Fresh Scripter

Registered: 2002-12-31
Posts: 22
Hi,
I'm having trouble one of my systems that I want to run iexplore.exe constantly and am trying to write a script to periodically check for the process iexplore.exe in case it gets closed. I searched the board and found a UDF that kills a task (findPROC i think) but not one that will execute one (besides proccheck, but I couldn't get that working [Frown] ). Can anyone help me in my quest, searches of the board aren't picking anything up.

Thanks for any help [Big Grin]

[ 11. February 2003, 21:04: Message edited by: Diane ]
_________________________
---------------------------- Diane Confucious say: Woman who keep washing liquid on top shelf, jump for joy

Top
#36307 - 2003-02-11 09:07 PM Re: Checking for a running process, execute if not running
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
break on

:top
if not findproc("iexplore.exe")
run("c:\...\iexplore.exe")
endif
sleep 5
goto top

[ 11. February 2003, 21:39: Message edited by: Radimus ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#36308 - 2003-02-11 09:30 PM Re: Checking for a running process, execute if not running
Diane Offline
Fresh Scripter

Registered: 2002-12-31
Posts: 22
Radimus,
Thanks for the quick reply. I see now it was in fact your modified UDF. I tried adding your code but it still won't open a browser. Here's my current code, can you see anything wrong ?(or right..hehe). I'm sorry for the ignorance, i'm not used to UDF's

code:
 break on

:top
if not findproc("iexplore.exe')
run "c:\program files\internet explorer\iexplore.exe"
endif
sleep 5
goto top


FUNCTION FindPROC($PROC,optional $COMPUTER, optional $terminate)
dim $GetObject, $Select
if not $computer
$computer=@wksta
endif
$GetObject="winmgmts:{impersonationLevel=impersonate}!//$COMPUTER"
$select="select * from Win32_Process where Name='$PROC'"
For each $Process in GetObject("$GetObject").ExecQuery("$select")
if $terminate
$Process.Terminate
endif
$FindPROC=$Process.ProcessId
Next
ENDFUNCTION

Thanks again
_________________________
---------------------------- Diane Confucious say: Woman who keep washing liquid on top shelf, jump for joy

Top
#36309 - 2003-02-11 09:32 PM Re: Checking for a running process, execute if not running
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
look at the typo in the: if not findproc() statement... mismatched quotes...
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#36310 - 2003-02-11 09:34 PM Re: Checking for a running process, execute if not running
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
What version of KiX ?
What OS on your systems ?
_________________________
We all live in a Yellow Subroutine...

Top
#36311 - 2003-02-11 09:37 PM Re: Checking for a running process, execute if not running
Diane Offline
Fresh Scripter

Registered: 2002-12-31
Posts: 22
Argh, damn typo's...hehe.
Thanks Radimus [Big Grin]

Waltz: 4.12, XP - but it's now working [Smile]
_________________________
---------------------------- Diane Confucious say: Woman who keep washing liquid on top shelf, jump for joy

Top
#36312 - 2003-02-11 09:58 PM Re: Checking for a running process, execute if not running
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
Good stuff...
BTW, there's a new pirate movie out...it's rated Arrrrrrghhh [Big Grin]
_________________________
We all live in a Yellow Subroutine...

Top
#36313 - 2003-02-11 10:05 PM Re: Checking for a running process, execute if not running
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
and it stars the Raiders and Buccaneers...
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#36314 - 2003-02-14 06:24 PM Re: Checking for a running process, execute if not running
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Another way to find such typo's can be find with our kixstrip tool.
You can find it on the pages Home - Kix Tools or Summary of Site
on our site.
Also documentation is available.
Our call is

kixstrip input.kix output.kix /block_check

The output is
code:
 BREAK ON

:top
IF NOT findproc("iexplore.exe')
RUN "c:\program files\internet explorer\iexplore.exe"
ENDIF
SLEEP 5
GOTO top

FUNCTION FindPROC($proc,OPTIONAL $computer, OPTIONAL $terminate)
DIM $getobject, $select
IF NOT $computer
$computer=@wksta
ENDIF
$getobject="winmgmts:{impersonationLevel=impersonate}!//$COMPUTER"
$select="select * from Win32_Process where Name='$PROC'"
FOR EACH $process IN GetObject("$GetObject").execquery("$select")
IF $terminate
$process.terminate
ENDIF
$findproc=$process.processid
NEXT
ENDFUNCTION

;($begin)
;
; fri 14-feb-2003 18:25:28 (kix 4.20 vs 4.00e)
;
;Summary KIXSTRIP: block structures
; - do:until [0:0]
; - for|each:in|to:step|next [1|1:1|0:0|1]
; - function:endfunction [1:1]
; - if:else:endif [3:0:3]
; - select:case:endselect [0:0:0]
; - while:loop [0:0]
;Warning KIXSTRIP: 1 line is incompleted.
; rerun program with option "/block_check /show_errors".
;Warning KIXSTRIP: some lines contains errors or possible errors.
; 1 line incomplete "double quotation".
; 1 line incomplete "left parenthesis".
; 1 line incompleted.
;Informative KIXSTRIP: 5 block_structures found.
;Informative KIXSTRIP: 1 UDF found.
;Informative KIXSTRIP: 1 label found.
;Summary KIXSTRIP: BREAK CALL DEBUG DISPLAY ENDFUNCTION EXECUTE EXIT FUNCTION GET GETS GOSUB GOTO OLExxx PLAY QUIT RETURN RUN SHELL SLEEP THEN USE
;Informative KIXSTRIP: 1 BREAK
;Informative KIXSTRIP: 1 ENDFUNCTION
;Informative KIXSTRIP: 1 FUNCTION
;Informative KIXSTRIP: 1 GOTO
;Informative KIXSTRIP: 1 RUN
;Informative KIXSTRIP: 1 SLEEP
;
;($end)
;($begin)
;
;Warning KIXSTRIP: 4 line incomplete "double quotation".
;Warning KIXSTRIP: 4 line incomplete "left parenthesis".
;Warning KIXSTRIP: 4 line incompleted.
;
;($end)

greetings.

btw: symbol  - on our homepage has been linked to related http://kixtart.org topic.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 4358 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 5.615 seconds in which 1.96 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org