即使完全信任,Silverlight (SLOOB) 也可以启动进程吗?
我的任务是编写一个带有 silverlight 浏览器应用程序的安装程序。我需要。
- 获取本地 EXE 的版本
- 检查 Web 服务以查看它是否是最新版本
- 下载 zip(如果不是)
- 解压 zip
- 覆盖旧的 EXE
- 启动 EXE
此安装程序应用程序现在是用 .NET WinForms 编写的,但使用 .NET Framework是人们下载的障碍。
推荐的解决方案是使用 SLOOB,但我不确定如何分配完全信任。如果我给予完全信任,我可以启动一个流程。
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
考虑到这一点,我怀疑您将必须通过 COM 接口使用 WMI 创建进程。归根结底,这使得这是一个非常困难的选择,并且由于多种原因(WMI 被禁用或安全、用户不会给予完全信任等)而很容易失败,我怀疑你会好得多如果需要的话,可以创建一个 .msi 部署包或类似的东西来下载框架。有很多可用的部署模型,几乎所有模型都比这个模型优越。
也就是说,如果您要执行以下操作:
要获取 COM 对象,您将需要使用
AutomationFactory.CreateObject(...)
API。 Tim Heuer 在此提供了一个示例。要实际执行 WMI 脚本编写,您需要创建
WbemScripting.SWbemLocator
对象作为根。从那里,使用 ConnectServer 方法获取指定计算机上的 wmi 服务。然后,您可以询问Win32_Process
模块来创建新进程。编辑:我花了一点时间来解决这个问题,即使在我的本地计算机上作为管理员,我也遇到了安全问题。正确的代码类似于:
Looking into this, I suspect you're going to have to create the process using WMI through the COM interface. At the end of the day, that makes this a very difficult option and very subject to failure due to a host of reasons (WMI being disabled or secured, user won't give full trust, etc.) I suspect you would be much better off creating a .msi deployment package or something similar that was able to go out and download the framework, if necessary. There are a lot of deployment models available, almost all of which feel superior to this one.
That said, if you're going to do this:
To get the COM object, you're going to want to use the
AutomationFactory.CreateObject(...)
API. Tim Heuer provides a sample here.To actually do the WMI scripting, you're going to want to create the
WbemScripting.SWbemLocator
object as the root. From there, use theConnectServer
method to get a wmi service on the named machine. You can then interrogate theWin32_Process
module to create new processes.Edit: I spent a little time working on this and, even on my local machine as Admin I'm running into security problems. The correct code would be something similar to:
Silverlight 4 将支持如下内容:http://timheuer.com/blog/archive/2010/03/15/whats-new-in-silverlight-4-rc-mix10.aspx#sllauncher
Silverlight 4 will have support for something like this: http://timheuer.com/blog/archive/2010/03/15/whats-new-in-silverlight-4-rc-mix10.aspx#sllauncher