Solved

MessageBox(?) needed to persist beyond application death

Posted on 2002-03-12
3
182 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
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
unable to delete all specified values regedit 38 538
Annoying "thing" blocks my view 4 114
Making an alias 7 101
"Black Box" Testing of Control System Software 2 70
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 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