如何检测是否打开了perforce会话? [英] How to detect if a perforce session is opened?

查看:68
本文介绍了如何检测是否打开了perforce会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检测是否已从本地外壳程序执行了批处理文件,或者通过在P4V中双击来检测到该批处理文件.有什么方法可以检查P4V是否打开?

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?

起初我想在中这样做道路, 但一如既往,TIMTOWTDI.有什么想法吗?

At first I thought to do it in this way, but as always, TIMTOWTDI. Any thoughts?

推荐答案

简短答案:不,不是真的.

详细答案:

您可以按照建议的方法,通过检查正在运行的p4v.exe进程来伪造它.但是,这只会告诉您P4V是否打开.如果您在另一个窗口中打开了P4V,并且从外壳程序运行了批处理文件(例如,在资源管理器中双击或从cmd提示符下运行它),则会得到误报.

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.

您可能会采用的另一种方法是确定脚本是否在Perforce客户端工作空间内.可以通过让脚本在其自己的路径上运行"p4 where"以查看其是否在工作空间中来完成此操作,但这取决于脚本的执行环境是否具有正确的连接设置,这取决于所配置的客户端计算机.很好"(例如,带有P4CONFIG文件和/或"p4设置",所有Perforce客户端应用程序都可以访问它-如果您仅使用P4V,则脚本将无法轻易访问其连接设置).

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).

这篇关于如何检测是否打开了perforce会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆