0
votes

I have a vbscript which I want to run at user logon using task scheduler. The task is set to run the script using the SYSTEM account (which I have to use because UAC is endabled).

The script works fine, but no message boxes in the script are displayed. I assume this is because it's running under the SYSTEM account as opposed to the logged on user.

Has anyone here conquered this issue? I need the script to run under the SYSTEM account but I also need the MsgBox in the script to get displayed.

1
Instead of running your VBScript at login, have you tried running a BAT file that just launches your VBScript? - Bond
Yes, unfortunately this doesn't work either. - Pickle

1 Answers

1
votes

In services turn on Interactive Services Detection. Make sure your task is interactive in it's properties. Now when there is a dialog from the services desktop you'll get a dialog telling you to look.

It appears to be slightly different in later OS's http://blogs.msdn.com/b/patricka/archive/2010/04/27/what-is-interactive-services-detection-and-why-is-it-blinking-at-me.aspx

Also try adding 0x00200000 to the flags for message box. This allows windows to pop up the dialog as you expect according to Help. This doesn't require Interactive.

Display a message box by calling the MessageBox function with MB_SERVICE_NOTIFICATION. This is recommended for displaying simple status messages. Do not call MessageBox during service initialization or from the HandlerEx routine, unless you call it from a separate thread, so that you return to the SCM in a timely manner.

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