Albert MN.
Albert MN.

Reputation: 730

How to make vbscript popup message always-on-top?

Anyone got a clue how to make a vbscript popup-message/box "spawn" on top of everything and not in the background...?

This is my script: :)

Set objShell = WScript.CreateObject("WScript.Shell")
Const wshYes = 6 
Const wshNo = 7 
Const wshYesNoDialog = 4 
Const wshQuestionMark = 32 
intReturn = objShell.Popup("Vil du annulere shutdown?", _
    20, "Shutdown om 5 minutter!", wshYesNoDialog + wshQuestionMark) 
If intReturn = wshYes Then 
    Wscript.Echo "Shutdown annuleret." 
    objShell.Run "C:\ProgramData\AutoShutdown\Annuler.bat" 
End If 

I am very bad at vbscript, I am just using this little part for my Batch program. Any help appreciated!

Upvotes: 5

Views: 7709

Answers (3)

Ste
Ste

Reputation: 2293

Adding + 4096 to your code will also work

20, "Shutdown om 5 minutter!", wshYesNoDialog + wshQuestionMark + 4096)


Here's google search link for objShell.Popup modal 4096

Upvotes: 0

Albert MN.
Albert MN.

Reputation: 730

It was simply by adding vbSystemModal

    120, "Shutdown om 5 minutter!", wshYesNoDialog + vbSystemModal + wshQuestionMark)

Upvotes: 3

user4946917
user4946917

Reputation:

The are wrappers around the API messagebox function. Just pass the numbers. Most msgbox functions just pass the numbers on so they don't need to understand them.

So use &h1000, &h2000, or &h40000

/*
 * MessageBox() Flags
 */
#define MB_OK                       0x00000000L
#define MB_OKCANCEL                 0x00000001L
#define MB_ABORTRETRYIGNORE         0x00000002L
#define MB_YESNOCANCEL              0x00000003L
#define MB_YESNO                    0x00000004L
#define MB_RETRYCANCEL              0x00000005L
#if(WINVER >= 0x0500)
#define MB_CANCELTRYCONTINUE        0x00000006L
#endif /* WINVER >= 0x0500 */


#define MB_ICONHAND                 0x00000010L
#define MB_ICONQUESTION             0x00000020L
#define MB_ICONEXCLAMATION          0x00000030L
#define MB_ICONASTERISK             0x00000040L

#if(WINVER >= 0x0400)
#define MB_USERICON                 0x00000080L
#define MB_ICONWARNING              MB_ICONEXCLAMATION
#define MB_ICONERROR                MB_ICONHAND
#endif /* WINVER >= 0x0400 */

#define MB_ICONINFORMATION          MB_ICONASTERISK
#define MB_ICONSTOP                 MB_ICONHAND

#define MB_DEFBUTTON1               0x00000000L
#define MB_DEFBUTTON2               0x00000100L
#define MB_DEFBUTTON3               0x00000200L
#if(WINVER >= 0x0400)
#define MB_DEFBUTTON4               0x00000300L
#endif /* WINVER >= 0x0400 */

#define MB_APPLMODAL                0x00000000L
#define MB_SYSTEMMODAL              0x00001000L
#define MB_TASKMODAL                0x00002000L
#if(WINVER >= 0x0400)
#define MB_HELP                     0x00004000L // Help Button
#endif /* WINVER >= 0x0400 */

#define MB_NOFOCUS                  0x00008000L
#define MB_SETFOREGROUND            0x00010000L
#define MB_DEFAULT_DESKTOP_ONLY     0x00020000L

#if(WINVER >= 0x0400)
#define MB_TOPMOST                  0x00040000L
#define MB_RIGHT                    0x00080000L
#define MB_RTLREADING               0x00100000L


#endif /* WINVER >= 0x0400 */

#ifdef _WIN32_WINNT
#if (_WIN32_WINNT >= 0x0400)
#define MB_SERVICE_NOTIFICATION          0x00200000L
#else
#define MB_SERVICE_NOTIFICATION          0x00040000L
#endif
#define MB_SERVICE_NOTIFICATION_NT3X     0x00040000L
#endif

#define MB_TYPEMASK                 0x0000000FL
#define MB_ICONMASK                 0x000000F0L
#define MB_DEFMASK                  0x00000F00L
#define MB_MODEMASK                 0x00003000L
#define MB_MISCMASK                 0x0000C000L

Upvotes: 1

Related Questions