Comments (23)
hallo, @oleg-shilo. Was my suggestion, but @Aaswin1996 want to use special restartmanager and dont want use shutdown.
from wixsharp.
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.
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.
@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.
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.
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.
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.
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.
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.
"shutdown.exe" is just a windows utility
from wixsharp.
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.
@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.
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.
But of course replace "explorer"
with whatever you need it to be
from wixsharp.
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.
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.
@oleg-shilo Its working outside only when I merge it with WixSharp it starts failing
from wixsharp.
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.
@oleg-shilo Same Error
from wixsharp.
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.
@oleg-shilo https://learn.microsoft.com/en-us/windows/win32/api/_rstmgr/
from wixsharp.
@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.
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)
- Info: SFXCA: Failed to create temp directory. Error code 5 HOT 3
- How to execute rollback imeediately If i click on cancel after install execute sequence has started ? HOT 3
- Overview of which SetupEventHandler is fired on which type of project HOT 2
- Wix Woolkit 3.14.1 not working "SFXCA: Failed to create temp directory. Error code 5" HOT 9
- MSI build is failing with failed to add file - Even path is available HOT 7
- How to see in WixSharp project which Wix toolkit version is being used AFTER it has been created? HOT 3
- Reg. Value Compare with NSIS BootStrapper HOT 3
- Some strings in Dialogs from .wxl are not replaced in Custom WPF UI HOT 6
- Snoop support HOT 3
- Incorrect FirewallException.IcmpTypesAndCodes property type HOT 3
- Using other (not Caliburn.Micro) MVVM framework HOT 1
- Sign Wixsharp dlls HOT 4
- [Question] Is there better way to create BA Installer for user choice ?
- Project GUID in Wix# script gets assigned as upgrade code and project ID is differently generated HOT 3
- Enable signing all user supplied files by default (continuation of #1543)
- Error on adding FirewallException HOT 1
- Hidden child features in FeaturesDialog.UserSelectedItems HOT 1
- Extracting a zip file during installation HOT 2
- Downgrading a DLL during an upgrade
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wixsharp.