开发者

Finding list of serial devices using LINQ

I am using the following code to find a list of Devices attached to COM Port.

ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\WMI", "SELECT * FROM MSSerial_PortName");

With Windows XP, the code works fine, but with Windows-7, I get an Access Denied Exception. I am running under fu开发者_StackOverflow社区ll administrative privilege in both the cases, then why would I face this error with Windows 7 and not XP.


You need to elevate privileges of your app: See this Q&A


I just ran your code under admin in my win7 rig and it worked properly while it failed within user context. Your process is running under UAC even though you yourself is logged in as admin. You need to secure elevated privileges for the application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜