Solved

MessageBox(?) needed to persist beyond application death

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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 …
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now