简体   繁体   English

如何获取JavaScript中的当前桌面路径? (Windows 7的)

[英]How can I get the current desktop path in JavaScript? (Windows 7)

I feel like this should be simple but I searched for a good half hour and couldn't find it. 我觉得这应该很简单,但是我搜索了一个半小时却找不到。

Basically I have an Adobe PDF file that runs a snippet of JavaScript to verify input and, if it deems the input ok, save the PDF to the desktop. 基本上,我有一个Adobe PDF文件,该文件运行JavaScript片段来验证输入,如果认为输入正确,则将PDF保存到桌面。 This works fine when I hard code in the desktop, ex.: 当我在桌面上进行硬编码时,这可以很好地工作:

var mypath = "/c/users/someusernamehere/desktop/";

However, we are trying to deploy this to many machines here, I do not want to have to hard code in everyone's desktop path. 但是,我们试图将其部署到这里的许多机器上,我不想在每个人的桌面路径中都进行硬编码。

Is there a way for JavaScript to get the desktop path of the current user? JavaScript有没有办法获取当前用户的桌面路径?

PS. PS。 All of our machines use Windows 7. 我们所有的机器都使用Windows 7。

/EDIT To clarify, this is not an Internet thing, it is all local. / EDIT要澄清的是,这不是Internet,而是本地的。 Just a PDF that is already stored on the user's machine accessing a JavaScript file stored in the same directory. 只是已经存储在用户计算机上的PDF可以访问存储在同一目录中的JavaScript文件。 That directory is: 该目录是:

C:\\Program Files (x86)\\Adobe\\Reader 11.0\\Reader\\Javascripts C:\\ Program Files(x86)\\ Adob​​e \\ Reader 11.0 \\ Reader \\ Javascripts

var objWSHShell = new ActiveXObject("WScript.Shell");
var strDesktopPath = objWSHShell.SpecialFolders("Desktop");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM