Roka545
Roka545

Reputation: 3636

Get a list of mapped drives as a Windows service.

I'm trying to get a list of mapped drives on my machine as a Windows service. I can get a proper list if I run my code as a normal program, but not as a Windows service. I've seen several posts regarding this topic but none give a clear solution.

I'm running the service on the same account that created the service, and the service has admin rights.

Does anyone know how to properly do this?

Upvotes: 0

Views: 1179

Answers (2)

NetMage
NetMage

Reputation: 26927

If you are in Windows 7 with UAC enabled, then the administrative session has different mapped drives then the regular user session. Open an administrative command prompt and run net show and check the mapped drive status.

Update: I have EnabledLinkedConnections set on my Windows 10 workstation so I don't see this issue there.

Upvotes: 1

Stuart Smith
Stuart Smith

Reputation: 2051

It is not possible

please see the following MSDN article

https://msdn.microsoft.com/en-us/library/windows/desktop/ms685143%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

If a service is configured to run under a user account, the system always creates a new logon session for the user and starts the service in that new logon session. Therefore, a service cannot manage the drive mappings established within the user's other sessions.

Upvotes: 2

Related Questions