Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bringing Window to Foreground...

Status
Not open for further replies.

baldhead

Technical User
Apr 27, 2004
111
0
0
US
I need some help bringing the popup window in this script to the foreground. What happens is the shutdown window pops up and then when this script executes the window which it diplays is pushed behind the Shutdown window. So how can I bring it to the front. I want me make things easy on the user. Here's the code:

Code:
' Abort Script for Application Reboot

Dim WshShell, BtnCode
Set WshShell = WScript.CreateObject("WScript.Shell")

BtnCode = WshShell.Popup("Has your machine been recently re-installed by a BGCEV IT person?", 35, "", 4 + 32)

Select Case BtnCode
   case 6      WScript.Echo("OK, We will allow the reboot to occur. It's necessary to install new applications")
   case 7      Call WSHShell.Run("cmd.exe /c %systemroot%\system32\shutdown.exe -a")

End Select

thanks for the help
 
Code:
' Abort Script for Application Reboot

Dim WshShell, BtnCode
Set WshShell = WScript.CreateObject("WScript.Shell")

BtnCode = -1
While BtnCode = -1
	BtnCode = WshShell.Popup("Has your machine been recently re-installed by a BGCEV IT person?", 10, "", 4 + 32)
Wend

Select Case BtnCode
   case 6      WScript.Echo("OK, We will allow the reboot to occur. It's necessary to install new applications")
   case 7      Call WSHShell.Run("cmd.exe /c %systemroot%\system32\shutdown.exe -a")
End Select

You could try this. It'll close and re-open the popup until either yes or no is selelcted. I dropped the time from 35 seconds to 10 so that it refreshed to the top more often.
 
there is an AppActivate method in vbscript you might like to consider, not sure if it will bring it to the front though,,,i would hope so
 
Skie,

Your idea does activate the window, it just doesn't bring it in front of the shutdown window. I still have to drag the box underneath the shutdown window to read the message. Is there a way to position the text box on the screen? This would probably be what we have to do.

thanks
 
The InputBox function admits X,Y coordinates in twips but lacks the time to wait ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I appreciate everyone's help. I will end up having this popup box appear before the shutdown dialogue appears. This eliminates this problem and makes things easier on the user. Here is the final code:

Code:
' Abort Script for Application Reboot

Dim WshShell, BtnCode
Set WshShell = WScript.CreateObject("WScript.Shell")

BtnCode = -1
While BtnCode = -1
    BtnCode = WshShell.Popup("Has your machine been recently re-installed by a BGCEV Information Technology person?", 0, "", 4 + 32)
Wend

Select Case BtnCode
   case 6       Call WSHShell.Run("cmd.exe /c %SystemRoot%\system32\shutdown -r -t 30 -c ""This Reboot is necessary to Install New Applications to your machine. In 30 Seconds your machine will restart, install these new applications, and then you can begin working.""")

   case 7      WScript.Echo("Continue Working, Sorry to Bother you.")

End Select
 
WScript.Echo("Continue Working, Sorry to Bother you.")

I don't tink I would ever tell the user that my script is a bother. They usually figure that out without my pointing it out to them. :)

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
yep you're right. I took it out. Good Point.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top