在javascript中设置工作目录
有人知道如何在 JavaScript 中设置工作目录吗?
我用于启动应用程序的代码是这样的:
// Create an object script
oL = new ActiveXObject("WScript.Shell");
oFile = '"C:/Application.exe"';
oL.run(oFile);
Does anyone know how to set the working directory in JavaScript before?
Code I use for launching an application is this:
// Create an object script
oL = new ActiveXObject("WScript.Shell");
oFile = '"C:/Application.exe"';
oL.run(oFile);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据 MSDN,您应该能够使用:
...假设您在 Windows Script Host 中运行此脚本,在这种情况下您可能应该在问题中明确说明 - 大约 99% 的 JavaScript 程序员仅在 Web 浏览器中使用该语言,其中这种语言事情只有在极其不寻常的情况下才有可能。
According to MSDN, you should be able to use:
...assuming you're running this script in Windows Script Host, in which case you probably ought to make that clear in your question - about 99% of JavaScript programmers only ever use the language in a web browser, where this kind of stuff is only possible under extremely unusual circumstances.
Javascript 通常在沙箱中运行,这意味着它无论如何都无法访问文件系统,因此设置 cwd 是没有意义的。
您想在什么环境中执行此操作(网站 javascript、使用 Rhino 运行的本地脚本等)以及您想实现什么目标?
Javascript typically runs in a sandbox that means it doesn't have access to the filesystem anyway, thus setting the cwd is meaningless.
What context are you trying to do this in (website javascript, local script running with Rhino etc.) and what are you trying to achieve?
Javascript 无法访问您的硬盘驱动器,那么为什么您应该能够设置工作目录呢?
Javascript dosent have access to your harddrive so why should you be able to set the working directory?