-1

In my application, i need all logical drives including mapped network drives. Its working fine without run as administrator. But my application by default run as administrator and i am not able to mapped network drives. I know that why its happened.

I am using DriveInfo.GetDrives() for collection drives.

My question is, can i possible to execute a single method(collecting all mapped drives) as current user privileges in the application that running as administrator?

Or any other ways to collect all network drives.

Thanks in advance.

Jitesh Byahut
  • 57
  • 1
  • 7
  • How will you know which user to execute the method as? Different users may have different mapped drives. If the app runs fine without administrator privileges, then you should just run it that way anyway. Running as administrator should be discouraged. – Chris Dunaway Nov 05 '14 at 19:08
  • Hey chris, In this wpf application, any user can use this page, so we have to show mapped drive by current logon user – Jitesh Byahut Nov 05 '14 at 19:35

1 Answers1

0

You could create another application without Administrator privileges and then run it from your main program.

Process.Start("myNormalApp.exe");

In "myNormalApp.exe" you place drives-mapping code. Then, you can write mapped drives to a file and open that file in your main application. It's a bit complex, but I think it's the only way. Let me say, however that I can't imagine why you say that an elevated application can't access to network drives (seems a bit strange to me)

The code is not tested, but it should work.

Hope this helps,

FWhite

PWhite
  • 141
  • 1
  • 12