I want to run my windows dot net application as administrator after just after installing msi . Please help
Asked
Active
Viewed 368 times
1
-
Is the msi created by you? vs2010? and does your MSI require Administrative privileges? – Cadburry May 15 '15 at 09:38
-
Yes , MSI created by me in vs10 . but I want to run my programme automatically after installing MSI as administrator – Pravin Wadichar May 15 '15 at 10:00
-
1Just have your installer run your app immediately. Since it runs elevated, your app will run elevated as well. Do keep in mind that you have only one shot at it, if anything goes wrong or the user is too flabbergasted to do the right thing then the opportunity will be lost. – Hans Passant May 15 '15 at 10:10
1 Answers
1
If your MSI require Administrative privileges you can directly run your application as a new System.Diagnostics.Procesas by overriding the Installer.OnAfterInstall method. Than the application will run under the same context.
If you have to force administrative context you can do it by the same way Create an instance of the System.Diagnostics.Process class and set the Verb property to "runas".
System.Diagnostics.Process process.Verb = "runas";
If you need to know the installed location of your application take a look at this approach: Getting Application path during the installation
EDIT
A approach is available on CodeProject: Launching Your Application After Install
-
Not working . I want to run application after installation as administrator – Pravin Wadichar May 15 '15 at 10:35
-