Reputation: 1138
I need to detect if a batch file has been executed from the local shell or by double-clicking within P4V. Is there a way I could check if P4V is open?
At first I thought to do it in this way, but as always, TIMTOWTDI. Any thoughts?
Upvotes: 0
Views: 385
Reputation: 71454
Short answer: no, not really.
Long answer:
You can try to fake it, as you suggest, by checking for a running p4v.exe process. This will only tell you if P4V is open, though. If you had P4V open in another window, and you ran your batch file from a shell (e.g. double clicking in Explorer, or running it from a cmd prompt), you'll get a false positive.
Another approach you might take would be determining whether the script is within a Perforce client workspace. That could potentially be done by having the script run a "p4 where" on its own path to see if it's within the workspace -- but it depends on the script's executing environment having correct connection settings, which depends on the client machine being configured "nicely" (e.g. with P4CONFIG files and/or "p4 set", which are accessible to all Perforce client apps -- if you use P4V exclusively its connection settings won't be readily accessible to your script).
Upvotes: 1