Sign in to follow this  
Followers 0
JPP

Scheduled Task with Messagebox

6 posts in this topic

Well it may very well be, that this is not a AutoIt problem, but quite sure someone from here can help. And I am really gratefull for any hint.

I have written and compiled a little message box program displaying some text and playing a sound, code see further down. I do call this from withín a DOS procedure under W2k prof and XP prof and home. And it works smooth an nice. However if I run it from as a sheduled tasks the problems start:

Under W2k it still works fine but under XP the messagebox will not pop up (but a net send does). I have carefully looked at any place I could find for NTFS access rights. I do run it under an admin account and the rights are there.

Any ideas?

JPP

AU3 Code:

; Messagebox "Title" "Line1^Line2 ...." ["Soundfile"]

; Error level 0=OK, 1=not enough arguments, 2= ill sound file

; MsgBox ( flag, "title", "text" [, timeout] ) -- ; onTop - 0x40000, STOP icon - 0x16

$ErrorLevel = 0

; Terminate script if not exactly 2 command-line arguments -- title + text

If $CmdLine[0] < 2 Then

MsgBox(0,"MSGBOX Error", "Call MSGBOX ""title"" ""line1^line2 ..."" [soundfile]" & @CRLF & "Errorlevel 0=OK, 1=ill call, need 2 or 3 arguments, 2=sound file does not exist")

Exit(1)

EndIf

; play sound and do NOT wait for it to end

If $CmdLine[0] == 3 Then

if FileExists ($CmdLine[3] ) Then

SoundPlay ($CmdLine[3], 0)

Else

$ErrorLevel = 2

EndIf

EndIf

; replace ^ by CR LF

$text = StringReplace ($Cmdline[2], "^", @CRLF)

; show messagebox

MsgBox(262144+16, $CmdLine[1], $text)

; all done

Exit ($ErrorLevel)

DOS BAT Code:

@echo off

if exist otto.dat msgbox "Information" "All Files available!"

if NOT exist otto.dat msgbox "Warning" "File missing^Restart!" %windir\Media\ding.wav

Share this post


Link to post
Share on other sites



Hi,

I still have not found the reason for that behaviour. But I do have some more information:

- as said before, all access rights are there and on top of it the scheduled task is run under an additional admin account.

- my msgbox.exe has 2 functions: play the sound and then display the messagebox popup window. The sound IS played, only the message box window does not pop up. The taskmanager shows msgbox.exe infitely staying there.It is obviously waiting for the OK click, which cant come, because there is no visible window. (This evening I will change it to use a timeout.)

Of course I double checked that the scheduler service has "Allow interaction with desktop" set.

While googleing I somewhere read, that scheduled tasks by default run under SYSTEM and that SYSTEM does not allow interactions. Well indeed my service SCHEDULED TASKS runs under system. But if I do change my command procedure and replace the call to msgbox.exe by a NET SEND and an additional call to SNDREC32.EXE that works as well!

I seem not to be the first one with such an problem, but I never have read a solution. Any ideas or any pointer to other knowledge ressources? Help is appriciated.

JPP

Share this post


Link to post
Share on other sites

BUMP

Gene

Hi,

I still have not found the reason for that behaviour. But I do have some more information:

- as said before, all access rights are there and on top of it the scheduled task is run under an additional admin account.

- my msgbox.exe has 2 functions: play the sound and then display the messagebox popup window. The sound IS played, only the message box window does not pop up. The taskmanager shows msgbox.exe infitely staying there.It is obviously waiting for the OK click, which cant come, because there is no visible window. (This evening I will change it to use a timeout.)

Of course I double checked that the scheduler service has "Allow interaction with desktop" set.

While googleing I somewhere read, that scheduled tasks by default run under SYSTEM and that SYSTEM does not allow interactions. Well indeed my service SCHEDULED TASKS runs under system. But if I do change my command procedure and replace the call to msgbox.exe by a NET SEND and an additional call to SNDREC32.EXE that works as well!

I seem not to be the first one with such an problem, but I never have read a solution. Any ideas or any pointer to other knowledge ressources? Help is appriciated.

JPP


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

OK,

meanwhile I know it is NOT an autoit problem. Simple Test: schedule NOTEPAD.EXE. I therefore consider the question in this forum being closed.

For those interested: I still have no solution, but it seems to me, that scheduled task generally are not interactive and by that do not allow a messagebox to pop up. Using NET SEND by itself is not interactive since the popup is produced in the user process. (I still have to test the AT /INTERACTIVE command.) Well ...

Oh, and my special thanks go to Gene for the one and only comment to my problem. It was really inspiring Gene!

JPP

Share this post


Link to post
Share on other sites

i just tested your problem with my own script and it plays a sound and shows the msgbox, don't know whats wrong here, maybe there is a problem in your script (waiting for sound to stop or something like this)

that's all i can say

hope you find your problem

maybe post your code here

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

If you use a username and password for the account that you are logged into, then it does show interactive. If other is used, then it will not show the messagebox but the script does execute and the sound is heard of the messagebox.

Edited by MHz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0