Wednesday, April 27, 2011

How to map a network drive to be used by a service

For this hack you will need SysinternalsSuite by Mark Russianovich:
Step one: Open an elevated cmd.exe prompt (Run as administrator)
Step two: Elevate again to root using PSExec.exe: Navigate to the folder containing SysinternalsSuite and execute the following command "psexec -s cmd.exe" you are now inside of a prompt that is "nt authority\system" and you can prove this by typing "whoami"
Step Three: Create the persistent mapped drive as the SYSTEM account with the following command "net use z: \servername\sharedfolder /persistent:yes"
It's that easy!
WARNING: You can only remove this mapping the same way you created it, from the SYSTEM account. If you need to remove it, follow steps 1 and 2 but change the command on step 3 to: "net use z: /delete"
NOTE: The newly created mapped drive will now appear for ALL users of this system but they will see it displayed as "Disconnected Network Drive (Z:)". Do not let the name fool you. It may claim to be disconnected but it will work for everyone. That's how you can tell this hack is not supported by Microsoft.


Hi all,

Thanks for the feedback.

I have finally had a chance to try and find a workaround to get the mapping done when the computer restarts. I have done limited testing, but so far this seems to have worked.

Follow this article to create a service with whatever name u like

I suggest creating something like

C:\Program Files\Resource Kit\Instsrv.exe MapDriveAsSystem C:\Program Files\Resource Kit\Srvany.exe

Then do the regedit as described in the article.

There is a bit more to it then just running the psexec command.


Then its upto you to set the service startup requirement. The service stays in started state although the psexec has completed its task. So if you were to manually delete the mapping the service would show as started regardless. To improvise on that. may be you could create a bat file with the psexec command to map as system and then a SC command to stop the same service.

Shouldnt matter though, as we are only doing this service creation to handle the mapping on a computer reboot.

Hope it helps.