Solved

MessageBox(?) needed to persist beyond application death

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

Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

630 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