从 C# 以编程方式创建快捷方式并设置“以管理员身份运行"财产 [英] Create shortcuts programmatically from C# and set "Run as administrator" property

查看:34
本文介绍了从 C# 以编程方式创建快捷方式并设置“以管理员身份运行"财产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经知道如何使用 IWshRuntimeLibraryWshShellClass 从我的 C# 应用程序以编程方式创建快捷方式.或者我可以使用 IShellLink.

I already know how to create shortcuts programmatically from my C# applications using IWshRuntimeLibrary and WshShellClass. Or I could use IShellLink.

现在,如果用户的 PC 运行的是 Windows Vista 或 Windows 7,我希望也能够以编程方式设置该快捷方式的以管理员身份运行" 属性.

Now, if the user's PC is running Windows Vista or Windows 7, I would like to be able to set the "Run as administrator" property of that shortcut programmactically as well.

这可能吗?如果是这样,如何?

推荐答案

虽然 Doug 的答案是这个问题的正确解决方案,但它不是这个特定问题的答案...

While Doug's answer is the correct solution to this problem, it is not the answer to this specific question...

要在 .lnk 上设置该属性,您需要使用 IShellLinkDataList COM 接口.伟大的 Raymond Chen 在他的博客上有 c++ 示例代码为此

To set that property on a .lnk, you need to use the IShellLinkDataList COM interface. The great Raymond Chen has c++ sample code on his blog for this

这篇关于从 C# 以编程方式创建快捷方式并设置“以管理员身份运行"财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆