I have been tasked with writing an installer with a silverlight out of browser application. I need to.
- get the version off a local EXE
- check a web service to see that it is the most recent version
- download a zip if not
- unpack the zip
- overwrite the old EXE
- 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
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.SWbemLocatorobject as the root. From there, use theConnectServermethod to get a wmi service on the named machine. You can then interrogate theWin32_Processmodule 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: