Giter Site home page Giter Site logo

Comments (23)

Torchok19081986 avatar Torchok19081986 commented on August 31, 2024 1

hallo, @oleg-shilo. Was my suggestion, but @Aaswin1996 want to use special restartmanager and dont want use shutdown.

from wixsharp.

oleg-shilo avatar oleg-shilo commented on August 31, 2024 1

Yes I understand the issue. Though it's not "in the WixSharp restarting applications". It happens when you do it from the MSI session.

Why it is happening can only be understood by digging in the restartmanager documentation. WixSharp documentation will not help you. Neiter WiX nor MSI. This is something specific for restartmanager.
You will need to do yourresearch

from wixsharp.

Torchok19081986 avatar Torchok19081986 commented on August 31, 2024

morning, remeber that you can always use AfterInstall Event from WixSharp in your msi packafge. Difficulty here is , to use external Process to do something. windows installer is bad to use something outside of installer, unfortunatelly.
If you want to use Restart manage is has to be part of your installer.
There is alternative way , to use bootstrapper installer, where you can do almost anything. Your BA installer is Ui with logic of windows installer and here you can use multuiple events from BA. Download latest version of wixsharp and go to bootstrapper folder. @oleg-shilo did very good job to show almost all cases for BA Installer.
With this you can control flow of installer completly. Modern installer are almost all , ~95% all BA Installer : free or paid. After install, all those ask for reboot or restart. Here you can use shotdown.exe with parameters to reboot or user logout immerdiatly and you dont need to use restart manager.
Best regards, Torchok.

from wixsharp.

Aaswin1996 avatar Aaswin1996 commented on August 31, 2024

@Torchok19081986 Cannot switch to a BA installer now .Need to use the restart manager as its the only API which I found which kills the application and restarts from where it was killed ...something like a restore .

from wixsharp.

Torchok19081986 avatar Torchok19081986 commented on August 31, 2024

then only one way direct to restart manager with MSI installer and msi package. Try afterinstall event from Wixsharp.
If this doesnt work here you can create Custom Action, but here is huge problem. custom action rely on current msi install session.

[CustomAction]
public static ActionResult StartRestartManager(Session session)
{
  //here comes the code, BUT somehow you have to  execute exe from here direct. something like session["INSTALLDIR"] = Process.Start("Restartmanager") will be not work, you have to deal with process startinfo and path to restart manager and here msi doesnt want it execute it. 

}

from wixsharp.

Aaswin1996 avatar Aaswin1996 commented on August 31, 2024

then only one way direct to restart manager with MSI installer and msi package. Try afterinstall event from Wixsharp. If this doesnt work here you can create Custom Action, but here is huge problem. custom action rely on current msi install session.

[CustomAction]
public static ActionResult StartRestartManager(Session session)
{
  //here comes the code, BUT somehow you have to  execute exe from here direct. something like session["INSTALLDIR"] = Process.Start("Restartmanager") will be not work, you have to deal with process startinfo and path to restart manager and here msi doesnt want it execute it. 

}

@Torchok19081986 Can you explain a bit more ?i Did not get the last part

from wixsharp.

Aaswin1996 avatar Aaswin1996 commented on August 31, 2024

then only one way direct to restart manager with MSI installer and msi package. Try afterinstall event from Wixsharp. If this doesnt work here you can create Custom Action, but here is huge problem. custom action rely on current msi install session.

[CustomAction]
public static ActionResult StartRestartManager(Session session)
{
  //here comes the code, BUT somehow you have to  execute exe from here direct. something like session["INSTALLDIR"] = Process.Start("Restartmanager") will be not work, you have to deal with process startinfo and path to restart manager and here msi doesnt want it execute it. 

}

@Torchok19081986 Can you explain a bit more ?i Did not get the last part

The issue I am facing is applications are getting shutdown but not restarted

from wixsharp.

Torchok19081986 avatar Torchok19081986 commented on August 31, 2024

that i said, you have to figured out, how to call restartmanager with parameters within CA. Try use class ProcessStartInfo and add verbs or verb to it. If your Restartmanager doesnt have parameter to restart apps after action, i think, you can try use Process Class , here you can kill and restart process by name. All another things you can , maybe, examinate log from wixshar in temp or window errorlog.

from wixsharp.

oleg-shilo avatar oleg-shilo commented on August 31, 2024

Actually, you can start any application from the AfterInstall event handler. The same way as from any other .NET application.

I am not sure what exactly you are referring to as RestartManager as this term is somewhat overused.
But you can definitely use this:

project.AfterInstall += args =>
{
    if (!args.IsUninstalling)
        Process.Start("shutdown", "-r")
};

Or if you want to use the Start extension method then you can call "shutdown".Start("-r");

from wixsharp.

oleg-shilo avatar oleg-shilo commented on August 31, 2024

"shutdown.exe" is just a windows utility

from wixsharp.

oleg-shilo avatar oleg-shilo commented on August 31, 2024

Then I have no idea what "restartmanager" is.
But the way using it will be the same regardless if it is setup event, raw CA, or a BA.

from wixsharp.

Aaswin1996 avatar Aaswin1996 commented on August 31, 2024

@oleg-shilo @Torchok19081986 RestartManager is a windows API which is written in c++ which helps in gracefully shutting down applicatioand and then restarting them from where it was shutdown .

I am using this as a wrapper code in c# to access c++ native functions :

https://gist.github.com/falahati/34b23831733151460de1368c5fba8e93

My use case is after installation I want to restart outlook and excel .Restart means shutdown and resume from where it was shutdown

from wixsharp.

oleg-shilo avatar oleg-shilo commented on August 31, 2024

Great, I looked at the code you shared. It is a pure interop (WIN API) so you have no dependency on anything.

then add that cs file to your project and then call the restart routine from the AfterInstall event handler:

project.AfterInstall += args =>
{
    if (!args.IsUninstalling)
        using (var rm = new RestartManagerSession())
        {
            rm.RegisterProcess(Process.GetProcessesByName("explorer"));
            rm.Shutdown(RestartManagerSession.ShutdownType.Normal);
            rm.Restart();
        }
}

from wixsharp.

oleg-shilo avatar oleg-shilo commented on August 31, 2024

But of course replace "explorer" with whatever you need it to be

from wixsharp.

Aaswin1996 avatar Aaswin1996 commented on August 31, 2024

your project and then call the restart routine from the AfterInstall event handler:

@oleg-shilo It does not work Shutdown happens but Restart Fails

from wixsharp.

oleg-shilo avatar oleg-shilo commented on August 31, 2024

Then you need to follow it with that "retstartmanager" solution that you use.

I say, try it outside of WixSharp (unless you already did it). Verify that it works and only when it does integrate it into your setup.

from wixsharp.

Aaswin1996 avatar Aaswin1996 commented on August 31, 2024

@oleg-shilo Its working outside only when I merge it with WixSharp it starts failing

from wixsharp.

oleg-shilo avatar oleg-shilo commented on August 31, 2024

OK, then maybe it the difference is caused by the fact that this API is called from the elevated process (your install session).
The real answer will be in that rstrtmgr.dll documentation if it exists.

However, you can just try to unelevate your afterinstall:

project.AfterInstallEventExecution = EventExecution.MsiSessionScopeImmediate;

Small chance, but it might work

from wixsharp.

Aaswin1996 avatar Aaswin1996 commented on August 31, 2024

image
image
@oleg-shilo Same Error

from wixsharp.

oleg-shilo avatar oleg-shilo commented on August 31, 2024

Wait, so you have the error information!
You know that it is the RestartManager service is failing. The event log is very clear about it.
So why are we looking at MSI to solve this problem?

I suggest you now look at the RestartManager service documentation for the solution.

from wixsharp.

Aaswin1996 avatar Aaswin1996 commented on August 31, 2024

@oleg-shilo https://learn.microsoft.com/en-us/windows/win32/api/_rstmgr/

from wixsharp.

Aaswin1996 avatar Aaswin1996 commented on August 31, 2024

@oleg-shilo The issue is that normally without MSI this works fine but when I include it in the WixSharp restarting applications starts failing

from wixsharp.

Torchok19081986 avatar Torchok19081986 commented on August 31, 2024

hallo, @Aaswin1996. If you have library of RestartManager , you coult try defered CA from External Assembly. I had same issue wiith 3. party Libs for creating Task for Windows TaskScheduler. External Assembly for execution in CA brought the solution for me. Thanks to @oleg-shilo.
there is example from oleg in latest wixsharp folder.
Source\src\WixSharp.Samples\Wix# Samples\DTF (ManagedCA)\Different Scenarios\ExternalAssembly. Here locatet sample.

from wixsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.