Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Kill running process before install

  • 29-06-2011 9:54am
    #1
    Registered Users, Registered Users 2 Posts: 4,113 ✭✭✭


    I have created an msi (C# VS2010) that installs an application and uninstalls the existing one beforehand (upgrades it in other words). However, if the application is running at the time of uninstall then it gives me the standard Windows message ("You must close the folllowing applications...."). I know how to kill a process in C# (Process.kill) but if I put in this code in the BeforeUninstall event in my installer class it doesn't get to it until after the above prompt.

    I have tried editing the msi with Orca by inserting the following into the ServiceControl table (INSERT INTO `InstallExecuteSequence` (`Action`, `Condition`, `Sequence`) VALUES ('_PreInstall', 'REMOVE=\"ALL\"', '1301')";
    Someone on the 'net told me this would terminate the running process but the msi gives an error when I do this ("The installer has encountered an unexpected error installing this package. Thsi may indicate a problem with this package. The error code is 2717").
    Surely there msut be some way to kill the app I am installing without requiring the user to manually end it?


Comments

  • Moderators, Sports Moderators, Regional Abroad Moderators Posts: 2,666 Mod ✭✭✭✭TrueDub


    lukin wrote: »
    I have created an msi (C# VS2010) that installs an application and uninstalls the existing one beforehand (upgrades it in other words). However, if the application is running at the time of uninstall then it gives me the standard Windows message ("You must close the folllowing applications...."). I know how to kill a process in C# (Process.kill) but if I put in this code in the BeforeUninstall event in my installer class it doesn't get to it until after the above prompt.

    I have tried editing the msi with Orca by inserting the following into the ServiceControl table (INSERT INTO `InstallExecuteSequence` (`Action`, `Condition`, `Sequence`) VALUES ('_PreInstall', 'REMOVE=\"ALL\"', '1301')";
    Someone on the 'net told me this would terminate the running process but the msi gives an error when I do this ("The installer has encountered an unexpected error installing this package. Thsi may indicate a problem with this package. The error code is 2717").
    Surely there msut be some way to kill the app I am installing without requiring the user to manually end it?

    I'd consider an app that simply killed an existing process to be badly-behaved - it would annoy me intensely. What if the user has some unsaved work that gets lost by an arbitrary killing?

    What's wrong with sticking with the message?


  • Registered Users, Registered Users 2 Posts: 4,113 ✭✭✭lukin


    TrueDub wrote: »
    I'd consider an app that simply killed an existing process to be badly-behaved - it would annoy me intensely. What if the user has some unsaved work that gets lost by an arbitrary killing?
    That's not possible because the app simply resides in the system tray, it's doesn't have an open interface like Word or something like that so when it is killed off the user won't even notice
    TrueDub wrote: »
    What's wrong with sticking with the message?
    Convience's sake; the user just wants to double-click on the msi and it installs over the new one. It will normally be rolled out by SCCM and there is an option in that to enter a command prompt before the msi you are rolling out kicks off so I could kill off the process that way.
    But in situations where they dont have SCCM and the msi is opened by the user from a shared drive or wherever, they want the running app killed off. I could put in a batch file alongside the msi to first kill the process, then kick off the msi but that's two files, which I don't like.


  • Registered Users, Registered Users 2 Posts: 16,414 ✭✭✭✭Trojan


    Not solving the problem, but I'd suggest that you walk the user past a screen that says something like "To upgrade, we need to stop/start the XYZ application, click continue to proceed", and wait for that before terminating. Also surely there's a system call to request a graceful termination rather than just doing a pkill.


  • Registered Users, Registered Users 2 Posts: 6,570 ✭✭✭daymobrew


    Can you send a WM_CLOSE message to the process you want to kill?


  • Registered Users, Registered Users 2 Posts: 4,113 ✭✭✭lukin


    I am using a batch file to kill the process, then calling the exe.
    I have a problem on Win 7 though, the batch file cannot kill the process (access denied). This is because there is no username listed under the Processes tab in Task Manager for the process I am trying to kill.
    This must be soemthing to do with the way the app is created; when it is opened on the PC, the process should always be associated with the current user.


  • Advertisement
Advertisement