2

I have a Visual Studio setup with a custom action written in C++. I need to launch a process from a custom action but both Install and Commit actions are run elevated and thus my process runs elevated too. I want the new process to run as a regular user.

I have seen Start exe after msi install but using current user privileges but it seems overly complicated and shows no code. I haven't got the time to experiment with an unknown API.

Are there any easy ways? Can I use VS Setup to define a non-elevated custom action or do something from the elevated custom action?

Community
  • 1
  • 1
wpfwannabe
  • 14,587
  • 16
  • 78
  • 129

2 Answers2

2

If you just want to test your code, it wouldn't be hard to update your built msi file with Orca. It'll let you add the dll with your code to the binary table, add a corresponding row to the customaction table, and add the action to a sequence.

If you need this to happen as part of your build process, you could accomplish the same thing with vbscript. The SDK comes with good sample vbscript code for interacting with an msi database, as described here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa372865%28v=vs.85%29.aspx

Ed.
  • 1,172
  • 6
  • 9
  • Thanks Ed. No, I do not want to use Orca. I need integrated build. It would be very tedious to have to do things manually. I will take a look at the samples and see if they can be made to do what I want. In the mean time, I have reverted to using a custom bootstrapper to do what I initially wanted. – wpfwannabe Nov 10 '11 at 08:03
1

Visual Studio setup projects do not support immediate custom actions. They are all deferred by default.

So either you use custom code to impersonate the current user or you switch to another setup authoring tool which supports immediate actions.

Cosmin
  • 21,216
  • 5
  • 45
  • 60
  • Thanks! I knew I'd hit a limitation of Setup projects sooner or later. It's so neat to use VS Setup project but I suppose it is good enough only for very basic scenarios. I decided to use a custom bootstrapper to achieve my goal and this works well. – wpfwannabe Nov 10 '11 at 08:05