即使完全信任,Silverlight (SLOOB) 也可以启动进程吗?

发布于 2024-08-25 12:08:26 字数 323 浏览 10 评论 0 原文

我的任务是编写一个带有 silverlight 浏览器应用程序的安装程序。我需要。

  1. 获取本地 EXE 的版本
  2. 检查 Web 服务以查看它是否是最新版本
  3. 下载 zip(如果不是)
  4. 解压 zip
  5. 覆盖旧的 EXE
  6. 启动 EXE

此安装程序应用程序现在是用 .NET WinForms 编写的,但使用 .NET Framework是人们下载的障碍。

推荐的解决方案是使用 SLOOB,但我不确定如何分配完全信任。如果我给予完全信任,我可以启动一个流程。

谢谢

I have been tasked with writing an installer with a silverlight out of browser application. I need to.

  1. get the version off a local EXE
  2. check a web service to see that it is the most recent version
  3. download a zip if not
  4. unpack the zip
  5. overwrite the old EXE
  6. start the EXE

This installer app is written in .NET WinForms now but the .NET framework is an obstacle for people to download.

The recommended solution is to use a SLOOB however i am not sure how to assign full trust. If i assign full trust can I start a process.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤芳又自赏 2024-09-01 12:08:26

考虑到这一点,我怀疑您将必须通过 COM 接口使用 WMI 创建进程。归根结底,这使得这是一个非常困难的选择,并且由于多种原因(WMI 被禁用或安全、用户不会给予完全信任等)而很容易失败,我怀疑你会好得多如果需要的话,可以创建一个 .msi 部署包或类似的东西来下载框架。有很多可用的部署模型,几乎所有模型都比这个模型优越。

也就是说,如果您要执行以下操作:

要获取 COM 对象,您将需要使用 AutomationFactory.CreateObject(...) API。 Tim Heuer 在此提供了一个示例。

要实际执行 WMI 脚本编写,您需要创建 WbemScripting.SWbemLocator 对象作为根。从那里,使用 ConnectServer 方法获取指定计算机上的 wmi 服务。然后,您可以询问 Win32_Process 模块来创建新进程。

编辑:我花了一点时间来解决这个问题,即使在我的本地计算机上作为管理员,我也遇到了安全问题。正确的代码类似于:

        dynamic locatorService = AutomationFactory.CreateObject("WbemScripting.SWbemLocator");
        dynamic wmiService = locatorService.ConnectServer("winmgmts:{impersonationLevel=impersonate,authentationLevel=Pkt}//./root/cimv2");

        dynamic process = wmiService.Get("Win32_Process");

        dynamic createParameters = process.Methods_["Create"].InParameters.SpawnInstance_;

        createParameters.CommandLine = "cmd.exe";

        wmiService.ExecMethod("Win32_Process", "Create", createParameters);

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 the ConnectServer method to get a wmi service on the named machine. You can then interrogate the Win32_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:

        dynamic locatorService = AutomationFactory.CreateObject("WbemScripting.SWbemLocator");
        dynamic wmiService = locatorService.ConnectServer("winmgmts:{impersonationLevel=impersonate,authentationLevel=Pkt}//./root/cimv2");

        dynamic process = wmiService.Get("Win32_Process");

        dynamic createParameters = process.Methods_["Create"].InParameters.SpawnInstance_;

        createParameters.CommandLine = "cmd.exe";

        wmiService.ExecMethod("Win32_Process", "Create", createParameters);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文