[英]Find absolute path of the exe file using javascript
Can we get the absolute path of the specified exe
file in javascript
. 我们可以在
javascript
获取指定的exe
文件的绝对路径。
(ie) If i give a file name like quicme
and i want to get the path of the file name as (即)如果我给文件名像
quicme
,我想得到文件名的路径为
c://programfiles/quicme.exe
No, you can't. 不,你不能。 You'd need access to the
PATH
environment variable for that, and JavaScript in browsers does not have access to that. 您需要访问
PATH
环境变量,浏览器中的JavaScript无法访问它。
In JScript on the Windows Script Host, you might be able to, though. 但是,在Windows脚本宿主的JScript中,您可能会这样做。 (If that's the case, please add the appropriate tags to your question.)
(如果是这种情况,请在您的问题中添加适当的标签。)
It's not a wanted feature to be able to access the user environment variables within a client-side script, especially if it's from a distant server. 能够在客户端脚本中访问用户环境变量并不是一个需要的功能,特别是如果它来自远程服务器。 There are serious security issues that could be exposed if it was allowed.
如果允许,可能会出现严重的安全问题。 Therefore, you cannot achieve that online with JavaScript.
因此,您无法使用JavaScript在线实现。
However, if you want it offline, a solution might be to do it with WScript, which would lead you to something like that to read the PATH environment variable: 但是,如果您希望它脱机,那么解决方案可能是使用WScript来实现,这会引导您进行类似的操作来读取PATH环境变量:
Set objShell = WScript.CreateObject("WScript.Shell")
Set colSystemEnvVars = objShell.Environment("System")
Set colUserEnvVars = objShell.Environment("User")
Wscript.Echo "Computer-specific PATH Environment Variable"
Wscript.Echo colSystemEnvVars("PATH")
Wscript.Echo "User-specific PATH Environment Variable"
Wscript.Echo colUserEnvVars("PATH")
For more information, take a look at this reference . 有关更多信息,请查看此参考 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.