Focus msgbox in vbscript

Discussion in 'Software' started by Agathorn, Feb 5, 2013.

  1. Agathorn

    Agathorn Private E-2

    Hi!

    I use a vbscript to shut down Internet Explorer and uninstall old java versions before we install the new java version. I use a msgbox in a vbscript to inform the user to shut down IE and then press "ok" in the dialogue box.
    The problem is that sometimes the window isnt in focus. That way the end user misses the little yellow window in the taskbar and the script never continues (I dont want to force shutdown of Internet Explorer without the user giving approval).
    Is there a way to force the vbscript msgbox window to pop up in front of ever other window all the time? The script will run on Windows XP X86 and Windows 7 X64 OS:es.

    Thanks in advance!

    Cheers
    Agathorn
     
  2. GermanOne

    GermanOne Guest

    vbSystemModal should do the trick
    Code:
    Select Case MsgBox("Do you want to ...?", vbYesNo Or vbQuestion Or vbSystemModal, "Shut down IE")
      Case vbYes
        WScript.Echo "Yes was clicked."
    
      Case vbNo
        WScript.Echo "No was clicked."
    
    End Select
    
    For additional information see MsgBox Function.

    Regards
    GermanOne
     
  3. Agathorn

    Agathorn Private E-2

    Thanks! It seems to work when I run the script "manually". The problem I saw before just happened sometimes when run from SCCM.
    The messagebox code now looks like this:

    if counter < 1 then msgbox strMsg, 4096, "IT-Department"
    I used 4096 which is the sum of 0 + 4096 (OK-button + vbSystemModal).

    We will now try it distributed and see if it makes a difference.
     
  4. GermanOne

    GermanOne Guest

    There are more options, undocumented for VBScript though.
    I assume that the MsgBox function calls the MessageBox WinAPI internally since I tried some of those options with VBScript (e.g. MB_TOPMOST) successfully.

    Give that a shot:
    Code:
    MsgBox strMsg, &h51000, "IT-Department"
    ... (MB_SYSTEMMODAL | MB_SETFOREGROUND | MB_TOPMOST) could be useful.

    Regards
    GermanOne
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds