开发者

Run exe after installation with user rights [closed]

开发者 https://www.devze.com 2023-03-30 16:34 出处:网络
Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 11 years ago.

Improve this question

I am using Visual Studio 2010 on windows 7 and developing a windows forms application in c# with a setup project ( msi ) that comes with visual studio.

I have added a custom action :

        protected override void OnCommitted(IDictionary savedState)
    {
        base.OnCommitted(savedState);
        Process.Start(@"Path");
    }

But when my application starts, it starts 开发者_开发技巧with the user "NTSYSTEM". I want it to start with the logged in windows user account instead.

How can i manage that?

Thank you.


3 posible solutions:

1) Login the application with whatever user you want via advapi32.dll, this requires that you either know the users login or that he inputs it.
2) Even cruder you can use runas to run the application, and again user either inputs the username and password or you do it.
3) You place the application in the automatic startup on the computer, (perhaps force a reboot ? ) and it will run in user context on reboot.


I solved it...

Added a javascript to run the program in the Post-Build property for the setup project and it started as a user instead of the system.

0

精彩评论

暂无评论...
验证码 换一张
取 消