Page 1 of 1 1
Topic Options
#198001 - 2010-03-08 04:07 PM how to get taskid from SHELLed script?
Sam_B Offline
Getting the hang of it

Registered: 2005-10-25
Posts: 68
Loc: Bern, Switzerland
Hi folks, I'm in the process of transforming a VBS script to kix. Now I'm stuck at the following VB line:

taskId = Shellid( "CMD.EXE /C " & outPath, 7)

the taskid is later used in the script to check if the submitted process is still running or not. Any id from you how i can get the process id of the submitted command with KIX?

Top
#198002 - 2010-03-08 04:31 PM Re: how to get taskid from SHELLed script? [Re: Sam_B]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
If the shelled task is a script itself then it can send it's own PID back to the parent using INI file or registry value.

If the SHELLed task (though you should probably be using RUN) is not a script then the parent script can search the process table for the PID.

For an example of how to do this see the EnumProcess() UDF: http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=7&Number=83681

Top
#198003 - 2010-03-08 04:38 PM Re: how to get taskid from SHELLed script? [Re: Richard H.]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
...though it might be easier to use the Wscript.Shell Exec method instead of KiXtart's built-in SHELL or RUN as this should provide you with the ProcessID as a property.

Here is a very simple example:
 Code:
$sCMD="notepad.exe"
$oExec = CreateObject("WScript.Shell").Exec($sCMD) 
"Process ID for '"+$sCMD+"' is "+$oExec.ProcessID+@CRLF


Edited by Richard H. (2010-03-08 04:43 PM)
Edit Reason: Added example

Top
#198005 - 2010-03-08 04:48 PM Re: how to get taskid from SHELLed script? [Re: Richard H.]
Sam_B Offline
Getting the hang of it

Registered: 2005-10-25
Posts: 68
Loc: Bern, Switzerland
Hi Richard, that's exactly what I was looking for. Many thanks!!
Top
Page 1 of 1 1


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

Who's Online
0 registered and 533 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.055 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

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