Solved

MessageBox(?) needed to persist beyond application death

Posted on 2002-03-12
3
188 Views
Last Modified: 2013-11-20
We have applications that must kill themselves so that their .exe files can be updated/overwritten. This code is complete and works.

What is needed now is a way for the application to tell the user that it closed on them to be updated.

Granted, we can always start a new process, mayhaps 'net send' or our own custom app, but I would really like a way to display the message box to the user without depending on external applications that will live beyond the complete exit of the application. Something like maybe PostMessage to the windows desktop and have it display the message box.

Summary: Must display a message to the user while overwriting the .exe file that triggered the display of the message. Prefer to not depend on any new .exe files.
0
Comment
Question by:Crius
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 150 total points
ID: 6859729
Here is one way.  
Save this into a file named PlzWait.js
//------------------------------ start of file
oShell= new ActiveXObject("WScript.Shell")
var nSecsToWait= 10; // 0=wait forever

var nRet= oShell.Popup(
  "Updating your UltraZippityDooDahWhizBang Pro Gold Plus \n"
  +"application program file to Version 7.325.122\n"
  +"\n"
  +"Please wait...",  nSecsToWait,
  "Updating...", 0 | 64
);
//------------------------------ end of file

Then launch it using ShellExecute.

Windows Scripting Host is kind of like a batch file in that it is a text file that is easily written and executed.  It is better than DOS-style batch files because there is no ugly DOS prompt involved.

It is very flexible.  You can pass it command-line arguments, use any available COM objects, launch programs, get user input,... you name it.

Caveats:  I'm not certain that WSH is always available on every computer (but I think it is installed by default) and I'm not certain that .js has always been associated with WSCRIPT.EXE (if not, you can just launch WSCRIPT.EXE and pass the name of the JS file to it).

=-=-=-=-=-=-=-
One more thought:  You could create a very small application program (all it does is show the message box) and store it as a resource in your EXE.  Your program reads the resource and writes it as DoMsgBox.Exe in the user's temp directory.  You could then launch it and quit your program.
 
-- Dan
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6859737
Incidently, if you are modifying an EXE (even if it is your own), there are many virus-detection programs that will go nuts on you.  Just a heads-up.

-- Dan
0
 
LVL 3

Author Comment

by:Crius
ID: 6869428
Awesome! Thank you for these alternatives. There is currently talk of ShellExec on iexplore.exe since everyone seems to have that (and load up a web page), but these are also worth discussion. :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question