服务无法访问映射驱动器

发布于 2024-08-30 21:43:58 字数 167 浏览 2 评论 0原文

我在许多论坛上读到,由于没有用户登录,因此无法从服务访问映射驱动器。

问题 1)我尝试将我的服务作为登录 - 作为某个帐户,并且我将我的网络驱动器映射到该帐户中。该服务仍然无法访问它。为什么?

问题 2)从同一个服务,我调用另一个进程。该进程将在什么用户帐户下运行?

谢谢

I have read in many forums that mapped drives are not accessible from a service as no user is logged on.

Question 1) I tried making my service as a log on - as some account and i had my network drive mapped in that very account. The service still cannot access it. Why?

Question 2) From the same sevice, i invoke another process. Under what user account will the process run?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

赤濁 2024-09-06 21:43:58

1)使用UNC路径,则不需要访问映射的驱动器号。至于为什么即使在同一帐户中运行也无法访问它们,在没有看到实际代码的情况下很难确定。

2)这取决于您如何启动该过程。如果您使用 ShellExecute()CreateProcess(),那么它会在调用线程的用户帐户中运行。如果您使用 CreateProcessAsUser()CreateProcessWithLogonW()CreateProcessWithTokenW(),则它将在您传入的用户帐户中运行。

1) Use UNC paths instead, then you do not need access to mapped drive letters. As to why you cannot access them even when running in the same account, it is hard to say for sure without seeing your actual code.

2) it depends on how you are launching the process. If you use ShellExecute() or CreateProcess(), then it runs in the user account of the calling thread. If you use CreateProcessAsUser(), CreateProcessWithLogonW(), or CreateProcessWithTokenW(), then it runs in the user account that you pass in.

朕就是辣么酷 2024-09-06 21:43:58

我在服务模式下运行 JBoss 时遇到了类似的问题,即使我执行服务,即使将“登录身份:”选项更改为已映射驱动器的同一用户,我的 Java 代码也无法访问映射驱动器。

然后我发现如果我可以使用相同的服务映射驱动器,那么它应该可以工作。

最后,在 service.bat 文件顶部添加一个简单的命令解决了该问题。

net use x: \\SERVERNAME\SHARENAME

I have faced similar problem wile running JBoss in service mode, my Java code was not able to access Mapped Drive even if i execute the service even after changing "Log on as:" option to the same user who has mapped the drive.

Then I figured out that if I can map the drive using the same service, then it should work.

And finally, adding just a simple command at top of service.bat file resolved the issue.

net use x: \\SERVERNAME\SHARENAME
一页 2024-09-06 21:43:58

在 XP 及更高版本上,服务无法访问映射驱动器,因为映射驱动器是每个用户的资源,因此它们取决于登录者。由于可能没有人登录,因此可能没有映射驱动器驱动器。

您的服务可能会映射驱动器本身。

Services don't have access to mapped drives on XP and beyond, since mapped drives are a per user resource, so they depend on who's logged in. Since it's possible for no-one to be logged in, it's possible that there are no mapped drives.

Your service may map a drive itself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文