0

I have developed an MSI setup with WiX, which includes a windows form application in c# .Net 2.0 framework and a windows service. I have to run my win form exe at windows start-up with User Account and for doing this I have used WTSQueryUserToken at my windows service project. I have written below codes at the OnStart() method of my windows service and followed the link1 and link2 and link3

    protected override void OnStart(string[] args)
    {

        base.OnStart(args);

        //TODO: place your start code here
        ThreadStart starter = new ThreadStart(bw_DoWork);
        Thread t = new Thread(starter);
        t.Start();

    }

    private void bw_DoWork()
    {

        string getSystem32Path = "";
        getSystem32Path = System32_SysWOW64_Folder();
        getSystem32Path = @getSystem32Path + "\\filename.exe";

        try
        {
                 CreateProcessAsUserWrapper.LaunchChildProcess(getSystem32Path);
        }
    }

I have run my set up at win-xp and win-7 with 32 bit and 64 bit machines and it gets installed successfully at all machines but fails to start my win form exe after machine restart.

I want to dump a file at User Profile, but while running my win app is dumping the file at system profile instead of user profile.

I want to run my win form at user account so that it dumps a file at user profile. How to do this? I have used WTSQueryUserToken to accomplish the same but unfortunately it is not working as I want.

Moreover, I have to set .Net Fraqmework 4.0 for my windows service project but all other project like win form project is running at .net Framework 2.0. I want to run my set up at .Net framework 2.0 and my win form should run at User Account. How can I do this?

Any kind of help in this regard will be highly appreciable.

Community
  • 1
  • 1
Tutun
  • 79
  • 1
  • 12
  • At the point when you call WTSQueryUserToken, is there actually a user logged in? Does you application actually need to interact with the logged on user, or do you just need to be running in the security context of a particular user account? (You can configure a service to run as a particular user, you do not need to use WTSQueryUserToken for that.) – Harry Johnston Feb 17 '15 at 23:54
  • Thanks @Harry for your reply. First of all my win form app should run with every user account whoever logs in. Now, my service is running as "LocalSystem". Is it so that the service starts whether a user is logged in or not and the method CreateProcessAsUserWrapper.LaunchChildProcess(filePath) inside OnStart() is already called while the user logs in? – Tutun Feb 18 '15 at 09:10
  • If your service is configured to start automatically when the system boots, then it will usually start before a user logs in. You have to wait for a user to log on before you can successfully call WTSQueryUserToken. – Harry Johnston Feb 18 '15 at 09:59

0 Answers0