Map a network drive to be used by a service

前端 未结 12 2157
再見小時候
再見小時候 2020-11-22 10:43

Suppose some Windows service uses code that wants mapped network drives and no UNC paths. How can I make the drive mapping available to the service\'s session when the servi

12条回答
  •  孤独总比滥情好
    2020-11-22 11:46

    Use this at your own risk. (I have tested it on XP and Server 2008 x64 R2)

    For this hack you will need SysinternalsSuite by Mark Russinovich:

    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 -i -s cmd.exe you are now inside of a prompt that is nt authority\system and you can prove this by typing whoami. The -i is needed because drive mappings need to interact with the user

    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 M$.

提交回复
热议问题