Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine Parent of Script

Status
Not open for further replies.

tyrant1969

Programmer
Dec 13, 2004
68
US
I have a VBscript that performs several steps for me but it can be called by one of a few different processes.

Most of the steps are identical for both processes - if process 1 calls the VBS file it does steps 1,2,3,4,5,6; but if process 2 calls the VBS file I want it to do 1,2,3,7,8,9 and if process 3 calls it I want it to do 1,3,4,7,9,10 and 11.

How do I tell what external program called my script?
 
The easiest way would be for the external programs to call it with an argument that identifies the program that called it.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
That would be ideal, but two of the three processes that call it right now we didn't create.

Any other thoughts?
 
In that case you may be able to navigate through the WMI Win32_Process class to use the .ParentProcess property to figure it out.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Man...you're everywhere! LOL Thanks, I'll give that a shot.
 
Using your suggestion of the ParentProcess property, along with the fact that I know that this is a unique process when it is called I was able to get my app's PID, determine the parent PID and look up the name of the parent.

Then, dependent on what the name of the parent was I executed the appropriate sub-set of the scripts.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top