bring minimized window to foreground or relaunch if closed -javascript, activeX WScript

Question : bring minimized window to foreground or relaunch if closed -javascript, activeX  WScript

Hello,
I have found several answers that are very close to fitting the problem I have.  I have an index.hta file that is using javascript, activeX and WScript.  Depending upon where a user clicks on this page, different applications are brought up, such as outlook, notepad etc..  If they are minimized, and the user clicks on the same area for that .exe, it is brought to the foreground.
Here is how that code is working:

var pOutlook = null;
function launchOutlook() {
var shell = new ActiveXObject( “WScript.Shell”);
if( pOutlook = null || pOutlook.Status == 1 ) // Status toggles between 0 & 1
{
pOutlook = shell.Exec( “C:/Program Files/Microsoft Office/Office11/outlook.exe”);
}
else
{
shell.AppActivate( pOutlook.ProcessID );
shell.SendKeys(“% x”);
}

The problem is with this part:

var pWorkload = null;
function launchWorkload() {
var shell = new ActiveXObject( “WScript.Shell” );
if( pWorkload == null )   // Status here is null at first, then always 1 so it is useless
{
pWorkload = shell.Exec( “WScript D:/mps/mps.js”);
}
else
{
shell.AppActivate( “Workload” );
shell.SendKeys (“% x”);   // I don’t think this has any effect here
}

This will bring up the Workload, and if it is obscured by another window and the user clicks on the hta page, it will bring the Workload page again to the foreground which is fine.
However, if the user minimizes the Workload page it just stays minimized, and if the user X’s out the workload page, they cannot get it back by clicking on the hta page.

I suppose this has something to do with the workload being a .js script and the other applications are window’s exe.

Please forgive my awkward description!!

Also the OS is XP and is running on a tablet PC, browser is IE 6

thanks so much for your time :):) .


Solution: bring minimized window to foreground or relaunch if closed -javascript, activeX  WScript

You can run

v.run(“D:/mps/mps.js”, 1, true);

In such case it will try to open default program assigned for js files on client machine.