comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Spawning EML Scripts in IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Spawning EML Scripts in IDL [message #51874] Thu, 14 December 2006 09:54
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
Matt wrote:
> Thanks for the great replies:
>
> To recap, it seems like there are two steps that I need to get a grasp
> of (followed by what I am begining to understand from responses - bear
> with me, I'm a total newbie) -
>
> 1. Identify whether the file I want to use in IDL is being used by
> another program.
>
> 2. If it is in fact being used, identify the process using it and kill
> it
>
> With regard to 1. Unfortunately, I can't use the SPAWN PID keyword to
> identify the process because I'm actually spawning a windows BAT file
> that in turn spawns the EML script. So the PID will identify the BAT
> process, which finishes in less than one second. Also, the File_test
> read/write keywords, from what I can tell, identify whether you have
> read/write permissions within that directory (am I wrong? In any case,
> the keywords are telling me that I can read/write a file that is being
> used by another process). SO... I'm beginning to think that I need to
> get a better grasp of IDL error handling functions. Can I just have IDL
> report/catch/capture the error (when it tries to move a file that it
> can't) and move on to the next line withouth going back to interactive
> mode?

You should be able to "catch" the error. Something like:

n = 0
while n < nFiles

catch, error
if (error ne 0) then begin
catch, /cancel
spawn, 'c:\kill_ems.vbs'
file_move, sourcePath+outfile, errorPath+outfile
endif

; rest of script here
n = n + 1


endwhile

When your script runs into a problem moving a locked file it will jump
into the catch block, kill the process, move the file someplace, and
then continue out the bottom.


> With regard to 2. It seems that killing an app can't be done through
> IDL but could be done through vb. Rick, thanks for the info, and thanks
> for giving me something to do over the weekend because I don't know ANY
> vb...

You should be able to cut and paste that into a text editor, save it as
"kill_eml.vbs" and you're set. Of course you will need edit the
strProcessKill variable to properly reflect the name of your EML
process. The only issue you may run into is if you are running multiple
EML scripts simultaneously. My simple script kills processes by name,
and it kills all of what it finds. If you need to kill particular
processes, you will need to write a vbs script that spawns the EML
process and returns the pid. Your kill script would then accept the PID
as an argument and kill based on PID, not name. But from your initial
description, this shouldn't be a problem.


-Rick


> Thanks helpful people...
>
> Matt
>
>
> Rick Towler wrote:
>> On windows you can use the WMI (Windows Management Interface). You
>> could probably do this via IDLcomIDispatch, but spawning vb script is
>> easier. Something like this should suffice:
>>
>> Dim objWMIService, objProcess, colProcess
>> Dim strComputer, strProcessKill
>> strComputer = "."
>> strProcessKill = "'eml.exe'"
>>
>> Set objWMIService = GetObject("winmgmts:" _
>> & "{impersonationLevel=impersonate}!\\" _
>> & strComputer & "\root\cimv2")
>>
>> Set colProcess = objWMIService.ExecQuery _
>> ("Select * from Win32_Process Where Name = " & strProcessKill )
>> For Each objProcess in colProcess
>> objProcess.Terminate()
>> Next
>>
>> WScript.Quit
>>
>> -Rick
>>
>> Robbie wrote:
>>> File locking is generally operating system dependent. Although, the
>>> file lock should be released if you terminate the EML process. You can
>>> find the process id by using the PID keyword in spawn. You can then
>>> terminate it using kill (UNIX) or a call to a MFC function (Windows)
>>>
>>> Robbie
>>>
>
Re: Spawning EML Scripts in IDL [message #51876 is a reply to message #51874] Thu, 14 December 2006 08:38 Go to previous message
Matt[1] is currently offline  Matt[1]
Messages: 23
Registered: December 2006
Junior Member
Thanks for the great replies:

To recap, it seems like there are two steps that I need to get a grasp
of (followed by what I am begining to understand from responses - bear
with me, I'm a total newbie) -

1. Identify whether the file I want to use in IDL is being used by
another program.

2. If it is in fact being used, identify the process using it and kill
it

With regard to 1. Unfortunately, I can't use the SPAWN PID keyword to
identify the process because I'm actually spawning a windows BAT file
that in turn spawns the EML script. So the PID will identify the BAT
process, which finishes in less than one second. Also, the File_test
read/write keywords, from what I can tell, identify whether you have
read/write permissions within that directory (am I wrong? In any case,
the keywords are telling me that I can read/write a file that is being
used by another process). SO... I'm beginning to think that I need to
get a better grasp of IDL error handling functions. Can I just have IDL
report/catch/capture the error (when it tries to move a file that it
can't) and move on to the next line withouth going back to interactive
mode?

With regard to 2. It seems that killing an app can't be done through
IDL but could be done through vb. Rick, thanks for the info, and thanks
for giving me something to do over the weekend because I don't know ANY
vb...

Thanks helpful people...

Matt


Rick Towler wrote:
> On windows you can use the WMI (Windows Management Interface). You
> could probably do this via IDLcomIDispatch, but spawning vb script is
> easier. Something like this should suffice:
>
> Dim objWMIService, objProcess, colProcess
> Dim strComputer, strProcessKill
> strComputer = "."
> strProcessKill = "'eml.exe'"
>
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" _
> & strComputer & "\root\cimv2")
>
> Set colProcess = objWMIService.ExecQuery _
> ("Select * from Win32_Process Where Name = " & strProcessKill )
> For Each objProcess in colProcess
> objProcess.Terminate()
> Next
>
> WScript.Quit
>
> -Rick
>
> Robbie wrote:
>> File locking is generally operating system dependent. Although, the
>> file lock should be released if you terminate the EML process. You can
>> find the process id by using the PID keyword in spawn. You can then
>> terminate it using kill (UNIX) or a call to a MFC function (Windows)
>>
>> Robbie
>>
Re: Spawning EML Scripts in IDL [message #51889 is a reply to message #51876] Wed, 13 December 2006 16:13 Go to previous message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
On windows you can use the WMI (Windows Management Interface). You
could probably do this via IDLcomIDispatch, but spawning vb script is
easier. Something like this should suffice:

Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = "."
strProcessKill = "'eml.exe'"

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next

WScript.Quit

-Rick

Robbie wrote:
> File locking is generally operating system dependent. Although, the
> file lock should be released if you terminate the EML process. You can
> find the process id by using the PID keyword in spawn. You can then
> terminate it using kill (UNIX) or a call to a MFC function (Windows)
>
> Robbie
>
Re: Spawning EML Scripts in IDL [message #51890 is a reply to message #51889] Wed, 13 December 2006 16:01 Go to previous message
Robbie is currently offline  Robbie
Messages: 165
Registered: February 2006
Senior Member
File locking is generally operating system dependent. Although, the
file lock should be released if you terminate the EML process. You can
find the process id by using the PID keyword in spawn. You can then
terminate it using kill (UNIX) or a call to a MFC function (Windows)

Robbie
Re: Spawning EML Scripts in IDL [message #51891 is a reply to message #51890] Wed, 13 December 2006 12:32 Go to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
> Is
> there a way to have IDL check if the file in question is being used by
> another application? I'd like to have IDL report a message stating if
> this is the case, and for IDL to move on to the next file without
> stoping the script. Does anyone have any suggestions?
>
> Matt
>

You may want to play with FILE_TEST and the /read and /write keywords

Jean
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: How to get a very large 2D projected surface image
Next Topic: Re: Licensing problem

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 20:02:11 PDT 2025

Total time taken to generate the page: 0.05099 seconds