Josh
Josh

Reputation: 1367

How to run my "C#" application under trustedinstaller account?

How do I run my application under the trustedinstaller account?
I tried creating a Visual Studio setup project and made an msi. But even that doesn't run under the trustedinstaller account. It runs only under the system account.

Can someone please guide me on how I can run my windows application under trusted installer account?

Just in-case you're wonder why I need it, its because I am supposed to copy some files into the winsxs folder for the client's C++ application to work.

Thank you so much in advance.

Upvotes: 3

Views: 9559

Answers (5)

Jason Shuler
Jason Shuler

Reputation: 399

Give one of these two utilities a try. DO NOT TAKE OWNERSHIP as suggested in other answers! This could break things worse than whatever small thing you are trying to do!

Method 1: Run as SYSTEM using PsExec

Download PsTools from Microsoft: https://learn.microsoft.com/en-us/sysinternals/downloads/psexec

psexec -s -i <path\to\executable

The -s option causes it to impersonate SYSTEM. -i makes it interactive.

This seems to handle most cases - even though it is system, it seems to be able to edit TrustedInstaller owned keys.

Method 2: Theoretically impersonate TrustedInstaller using Nirsoft AdvancedRun

https://www.nirsoft.net/utils/advanced_run.html

This free tool is from Nirsoft (a long-standing, trustworthy provider of awesome utilities), and can be used in GUI and command line mode.

This explicitly allows you to select a specific service account, although the process shows up running as SYSTEM, it seems to be able to edit TrustedInstaller owned things.

Upvotes: 3

paulm
paulm

Reputation: 5882

This can't be done, instead you must:

  1. Run with Administrator rights.
  2. Take ownership of the object (registry key/directory/whatever).
  3. Allow yourself r/w access by changing the DACL.
  4. Now make your changes.
  5. Set the owner back to trusted installer and undo the permission changes you've made.

Upvotes: 0

Mak
Mak

Reputation: 49

Can someone please guide me on how I can run my windows application under trusted installer account?

You can use devxexec

For example:

devxexec.exe /user:TrustedInstaller cmd

Upvotes: 4

EarthQ
EarthQ

Reputation: 19

Unfortunately devxexec.exe /user:TrustedInstaller cmd does not work in Windows 8. It does run other programs fine though, but not cmd.

Upvotes: 1

David Heffernan
David Heffernan

Reputation: 612794

That's not how you are supposed to do it. You are meant to mark your .msi as requiring administrator rights and then the system will show the user a UAC elevation dialog when they install.

This article has more details on Trusted Installer. The bottom line is that it's not actually a user but a service. In any case, it's not the solution to your problem.

Upvotes: 4

Related Questions