How to start Process Under windows User.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dj12345
    New Member
    • Jan 2008
    • 14

    How to start Process Under windows User.

    Hi,

    Can anybody solve my problem.

    I have one small windows Application. In this application i have added Installer Class. which start a program after the setup project installation is completed.

    Code:
      private void Installer1_AfterInstall(object sender, InstallEventArgs e)
            {
                
                   
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
                    Process p = new Process();
                    InstallContext cont = this.Context;
                    //ProcessStartInfo inf = new ProcessStartInfo(cont.Parameters["assemblypath"]);
                    p.StartInfo.FileName = (cont.Parameters["assemblypath"]);
                    p.StartInfo.UseShellExecute = false;
                    p.StartInfo.LoadUserProfile = true;
                    p.Start();
    
    }
    when setup is completed it starts the program. but the problem is it starts the under the user "NT AUTHORITY\SYSTE M", I want to start this program under the user which is logged in (User Logged in user windows authentication) .
    Last edited by tlhintoq; Feb 15 '10, 02:43 PM. Reason: [CODE] ...Your code goes between code tags [/CODE]
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      Installing a secondary program after the first program installs. Looks like a virus to me.

      Comment

      • sashi
        Recognized Expert Top Contributor
        • Jun 2006
        • 1749

        #4
        What if the currently logged user doesn't have Administrator access? How are you going to deal with this? My advice will be starting the service with "Local User Account"

        Good luck :)

        Comment

        • dj12345
          New Member
          • Jan 2008
          • 14

          #5
          Hi Sashi..

          Thanks for your reply.

          Actually I dont want to create a service.. I am creating a Setup & Deployement project. When user install the setup then after completing the installation the program which is just installed should start immediately.

          So in this Setup project i am adding Custome Action. In this the installer after install will start the actual program. so I am starting the program using Process.Start() . But it starts under "NT AUTHORITY\SYSTE M" . I want to start this program under the user which is logged in (User Logged in user windows authentication) .

          Hope you have understood my problem..

          Thank you...

          Comment

          • sashi
            Recognized Expert Top Contributor
            • Jun 2006
            • 1749

            #6
            Why not post your code segment here? Lets see how it can be modified. Take care :)

            Comment

            • pconno3
              New Member
              • Aug 2010
              • 2

              #7
              I am having the exact same problem, did you ever figure this out?

              Comment

              • dj12345
                New Member
                • Jan 2008
                • 14

                #8
                Hi pconno,

                The Setup & Deployment project was not working for me.. Creating setup project using Visual Studio 2005 was only working under windows xp and not under windows 7. So finally I used "Inno Setup" application to create setup. and this works under xp and windows 7. creating setup project using "Inno Setup" solved my problem. It is free and you can easily create setup and you can also write some programing logic also. http://www.jrsoftware.org/isinfo.php

                Comment

                • pconno3
                  New Member
                  • Aug 2010
                  • 2

                  #9
                  Thanks

                  Thanks dj12345,
                  Inno seems to work perfectly for me too.

                  Comment

                  Working...