Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

Using global variable or Finding process for given application to close current instance

$
0
0

Hello to all.

As this is my first post, forgive me if this is in the wrong forum.

 

I was wondering if it was possible to determine the process for a given application.  To expand on this a little more, I have created a script that opens a new excel application to pull some data.  Once complete, I want to close the workbook (I have this complete), and close the application (pending).  Since I put all my Excel functions into a separate script, based on OO programming in other languages, the $excel reference is not available.

Would it be better to include everything in a single script, make this variable ($excel) a global (will this work since the function is in a separate script), or lookup the process for the given application and close it?  I only want to close the single instance that is opened as a part of the script(s), and not close all Excel instances.

 

In my testing, I set the $excel variable to a global, but wonder if this is the best approach.


Viewing all articles
Browse latest Browse all 10624

Latest Images

Trending Articles



Latest Images