服务无法访问映射驱动器 [英] Service not able to access a mapped drive

查看:178
本文介绍了服务无法访问映射驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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?

问题 2) 在同一个服务中,我调用了另一个进程.该进程将在哪个用户帐户下运行?

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

谢谢

推荐答案

1) 改用 UNC 路径,这样您就不需要访问映射的驱动器号.至于为什么即使在同一帐户中运行也无法访问它们,如果没有看到您的实际代码,就很难确定.

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) 这取决于您启动进程的方式.如果您使用 ShellExecute()CreateProcess(),则它会在调用线程的用户帐户中运行.如果您使用 CreateProcessAsUser()CreateProcessWithLogonW()CreateProcessWithTokenW(),则它会在您传入的用户帐户中运行.

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.

这篇关于服务无法访问映射驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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