Solutions for Windows service not accessing the network share drive

Source: Internet
Author: User
Tags net command

When I mapped a network drive to this machine, I found that the program was able to access the read network drive directly, but it could not be accessed when the native program was running as a native Windows service.

Qdir::exist (folder) access in Qt failed. This is caused by mapping the network drive, requiring the service program to run the rights account and the remote shared file for the machine to run in the same domain (domains)

Below, with Pstool This tool, it directly uses the System account permissions to map network drives. This allows the remote drive and native service to be in the same domain.

Note: this is a relatively hack approach and is not recommended. Microsoft is not supported.

1. Create a network drive with PsExec:

Admin permissions run cmd, and then run psexec-i-S Cmd.exe

Then run the following command in the newly opened CMD window to map the network drive Z-disk, net use Z: \\server_ip\share_folder/persistent:yes

The net command above may let you enter the remote system user name and password, my remote is XP, so the user name password is: administrator/no password

Note: all Microsoft Windows system default administrator users are administator and the password is set by yourself, the system does not have a default password

2. Running the native Windows service, successfully accessing the network drive Z

References

Http://stackoverflow.com/questions/18632193/directory-exists-returns-false-for-mapped-drive-in-c-sharp-coding

Http://stackoverflow.com/questions/3622089/windows-service-cant-access-network-share

Http://serverfault.com/questions/177139/windows-service-cant-access-network-share

Http://stackoverflow.com/questions/182750/map-a-network-drive-to-be-used-by-a-service

Https://technet.microsoft.com/en-us/sysinternals/psexec (pstool tool download)

Solutions for Windows service not accessing the network share drive

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.