restarting explorer.exe at the end of the installation

Got a problem you cannot solve? Try here.
tzachk
Posts: 171
Joined: Wed Jul 18, 2012 12:14 am

restarting explorer.exe at the end of the installation

Postby tzachk » Wed Apr 20, 2016 9:32 am

Hi,

I'm trying to find a way of restarting explorer.exe at the end of the installation process.
The issue is that the user executing the installer (admin account with runas) might be different than the logged in user, and I need to start the explorer.exe after I terminate it with the logged in user credentials. Do you know of a simple way of doing this task?

Regards,
T.

bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Re: restarting explorer.exe at the end of the installation

Postby bokkie » Wed Apr 20, 2016 11:53 am

T,

Here's a C# fragment I found:

Code: Select all

foreach(Process p in Process.GetProcesses())
{
    try
    {
        if(p.MainModule.FileName.ToLower().EndsWith(":\\windows\\explorer.exe"))
        {
            p.Kill();
            break;
        }
    }
    catch
    { }
}
Process.Start("explorer.exe");


It looks like it should do what you want. Assuming you're okay with DotNet, create a new console application and put the above code in it. Compile and what have you. Then, in theory, you should be able to run the executable as a DOS command.

The Windows PowerShell command is also quite powerful so you could write PS commands into a batch file and execute that at runtime. To save creating physical files on disk you can use the MSIcode file bag statement which'll give you a temporarily persistent file which is removed when the installation media terminates. Another option is to use the same procedures I just described and invoke the native engine. Copy the executable or batch file to disk, run it to restart the explorer and then delete the file afterwards and then turn off the native engine. There are a lot of ways of baking the same cake.

I might have overlooked it but I couldn't see any obvious MSIcode statement that would do things for you in a, sort of, embedded manner as part of the IDE. I'll let you explore (sorry for the pun :D) things in more detail. If there's no simpler way in the IDE-cum-MSIcode and DotNet isn't on your list of 1000 Things To Do Before You Kick The Bucket, let me know and I'll cobble an executable together for you and test it and, if it passes muster, I'll pass it onto you.
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP

bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Re: restarting explorer.exe at the end of the installation

Postby bokkie » Thu Apr 21, 2016 3:55 am

T,

I've attached a plugin that might do what you want. You can find it here: viewtopic.php?f=3&t=10646
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP

tzachk
Posts: 171
Joined: Wed Jul 18, 2012 12:14 am

Re: restarting explorer.exe at the end of the installation

Postby tzachk » Thu Jun 16, 2016 10:59 am

Hi Bokkie,

thank you for your answer.
I tried this approach. Because the installer executes as administrator user, executing the console app will create an explorer under the administrator account, and not the user currently login to the machine.

Regards,
Tzach


Return to “Technical Support”

Who is online

Users browsing this forum: JohnGaver and 77 guests