Question
How to map network shares into drives to a Windows service permanently
Answer
In order for network shares to be mapped into drives and accessible within Windows services, you need to login as the NT AUTHORITY\SYSTEM account.
To do this, download the Sysinternals Suite from Microsoft and unzip it to a directory say C:\TEMP
The following steps assume that you've unzipped SysInternals to C:\TEMP and all the executables are in there.
- Launch a command prompt as Administrator.
- CD \TEMP
- psexec -i -s cmd.exe
This launches a new command prompt window and step 4 should be performed in that new window. - net use Z: \\servername_OR_IP\sharedfolder /u:username /persistent:yes
Provide the credentials of a user having access to the shared folder. - Create a script that runs on computer startup that has only line 4 in it acccording to Microsoft's article: Assign Computer Startup scripts.
If you need to remove it
- Launch a command prompt as Administrator.
- CD \temp
- psexec -i -s cmd.exe
This launches a new window. Step 4 should be entered in that window. - net use Z: /delete
NOTE: If you are using Windows 8 or Windows 2012 and you receive an error executing the net use command please follow this articlefrom Microsoft support knowledge base to fix it.
要将网络共享永久映射到Windows服务驱动器,需以NTAUTHORITYSYSTEM账户登录。使用SysinternalsSuite中的工具,如psexec在提升权限的命令提示符中执行netuse命令,指定共享服务器、用户名和密码,并设置为持久连接。创建一个启动时运行的脚本来执行这些步骤。若要删除映射,同样使用netuse命令但添加/delete参数。
https://www.ibm.com/support/pages/how-map-network-shares-drives-windows-service-permanently
5614

被折叠的 条评论
为什么被折叠?



