<p>I've got a problem here with an MSI deployment that I'm working on (using <a href="http://en.wikipedia.org/wiki/InstallShield" rel="nofollow noreferrer">InstallShield</a>). We have a program running in the background that needs to run per-user, and it needs to start automatically without user intervention.</p>

<p>The problem is with <a href="http://en.wikipedia.org/wiki/Group_Policy#Operation" rel="nofollow noreferrer">Group Policy Object</a>/<a href="http://en.wikipedia.org/wiki/Active_Directory" rel="nofollow noreferrer">Active Directory</a> (GPO/AD) deployment the application is started in the SYSTEM context before anyone is logged in rather than as the user who is about to log in. The application can only run once per user, and it seems that the SYSTEM process prevents the USER process from starting. This means the PCs need to be rebooted twice before the software can be deployed to the users. How do we to stop this?</p>

<p>Basically the current workflow is: </p>

<ol>
<li>Installation/upgrade runs... kill background application</li>
<li>Install new files</li>
<li>Startup background application</li>
</ol>

<p>This works for published applications and interactive <a href="http://en.wikipedia.org/wiki/Windows_Installer" rel="nofollow noreferrer">MSI</a> installations - it's only 'assigned' applications that seem to have the problem. As step 3 happens in the SYSTEM context rather than the user context :(</p>

<p>Ideally, I'd have the development team patch the EXE file to prevent launching in the SYSTEM context, but that's a release cycle away, and I'm looking for an installer-based solution for the interim.</p>

<p>(I don't know Installscript... So I'm guessing <a href="http://en.wikipedia.org/wiki/VBScript" rel="nofollow noreferrer">VBScript</a> is probably the way to go if there's no native InstallShield stuff I can use.)</p>

[{'answer_id': 29772, 'author': 'On Freund', 'author_id': 2150, 'author_profile': 'https://Stackoverflow.com/users/2150', 'pm_score': 4, 'selected': True, 'text': '<p>You can use the <a href="http://msdn.microsoft.com/en-us/library/aa369780(VS.85).aspx" rel="noreferrer">LogonUser</a> property of Windows Installer as a condition to the action launching the EXE.</p>\n'}, {'answer_id': 29803, 'author': 'saschabeaumont', 'author_id': 592, 'author_profile': 'https://Stackoverflow.com/users/592', 'pm_score': 1, 'selected': False, 'text': '<p>AHA! I knew there had to be a cleaner solution... the code I was working on was starting to look something like this:</p>\n\n<pre class="lang-vb prettyprint-override"><code>On Error Resume Next \nstrComputer = "."\nSet objWMIService = GetObject("winmgmts:" _\n    &amp; "{impersonationLevel=impersonate}!\\\\" &amp; strComputer &amp; "\\root\\cimv2")\nSet colProcessList = objWMIService.ExecQuery _\n    ("Select * from Win32_Process Where Name = \'BackgroundProcess.exe\'")\nFor Each objProcess in colProcessList\n    colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain)\n    If strNameOfUser = "SYSTEM" Then    \n        objProcess.Terminate()\n    End If\nNext\n</code></pre>\n'}, {'answer_id': 6024905, 'author': 'Stein Åsmul', 'author_id': 129130, 'author_profile': 'https://Stackoverflow.com/users/129130', 'pm_score': 1, 'selected': False, 'text': '<p>I wouldn\'t rely on a Windows installer property to accomplish this. If I understand correctly you want to run an EXE file once per user - probably to set up user defaults? The only time you can guarantee that you are in the right context is when the user actually logs in. With the amount of impersonation going on these days in the average deployment scenario I just don\'t trust anything but a real user login as the correct stage to run EXE files.</p>\n\n<p>There are too many problem sources: custom permission and priviledge lockdowns, terminal server lockdown, virtualization redirects, impersonation run by the deployment system, operating system overrides for registry writes etc...</p>\n\n<p>Microsoft has a feature called Active Setup which will allow you to run "something runnable" once per user, on logon. This can be anything from a script to an executable. See my answer here for more details: <a href="https://stackoverflow.com/questions/1423687/updating-every-profiles-registry-on-windows-server-2003">Updating every profile&#39;s registry on Windows Server 2003</a></p>\n'}]
['https://Stackoverflow.com/questions/29760', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/592/']