# howto call external program from autoit script running as a service?

## Recommended Posts

Hello,

I've written a "Watchdog" autoit script that is supervising some service that tends to stopp itself time by time. If stopped, it's restarted by that script and a warn email has to be send to the local admin.

When running that script as a regular program that is working fine. The BLAT windows do pop up for 1 second.

When running as a service, the "watched" service is started again, so the whole "watchdog" itself is running. But the call of BLAT.EXE doesn't work, no warn emails are sent.

Maybe something like "interactive" is requiered to allow the service to call BLAT.EXE, as BLAT might be dependant on a "own CMD window"?

I've also wondered about a %PATH% issue, so I coded the full path to my copy of BLAT.EXE into that script, no change.

Any ideas?

Thanks, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

##### Share on other sites

Do you absolutly have to use blat?

Because, there is a better AutoIt SMTP application out...

Jos posted it a while back.

you should search for that, and use that instead.

(Just a thought)

Although you do need an smtp server set up too use it >.>

Isn't blat its own? if you don't wanan use gmail or yahoo or any other than your local then, never mind stick with blat

And are you using srvany.exe to add your services? it won't work on some applications without that.

Edited by BackStabbed

tolle indicium

##### Share on other sites

Do you absolutly have to use blat?

absolutely no , I'm just used to it for longer time

Because, there is a better AutoIt SMTP application out...

Jos posted it a while back.

you should search for that, and use that instead.

(Just a thought)

Although you do need an smtp server set up too use it >.>

Sorry, my English, I cannot follow you here: "Although you need an SMTP server set up too use it" ??

Isn't blat its own?

BLAT.EXE is a 100% indipendent SMTP mailer EXE.

As it's extremly fast it's abused by some idiots to send bulk UCE. That's the reason why some people hate it. (They should hate the abusers instead!)

I think it's very useful in any scripts to send status emails (CMD, AU3, ...)

The Syntax is pretty easy:

Func _SendEmail($sender = "sender@somewhere.com",$subject = "This is a Status Info Mail", $Priority = "") #cs BLAT priority:$low = " -priority 0"
$high = " -priority 1"$normal = ""
$Logfile will be send along with the email as attachment$Blat = full\path\to\blat.exe
#ce
RunWait($Blat & " -install 10.27.1.5 " &$sender) ; -install <receiving mail server>; $Sender="sender@somewhere.com" Run($Blat & $LogFile & ' -to admin@domain.com -subject ' &$subject & \$Priority)
EndFunc   ;==>_SendEmail

if you don't wanan use gmail or yahoo or any other than your local then, never mind stick with blat

Using some external freemailer is *NOT* an option.

And: I don't wanna STICK with blat.exe, I wanna GO with blat

And are you using srvany.exe to add your services? it won't work on some applications without that.

I used "RunAsSvc.exe", and the service itself IS running fine: Logfile entries ARE written, and the watched service IS restarted when I intentionally stop it. Just the status emails aren't sent, so I suspect that this script cannot start an external program when running as a service? When I run it as regular EXE (doubleclick from local logon) it's working fine.

Why?

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

##### Share on other sites

What if your SMTP port was blocked...?

"Although you need an SMTP server set up too use it"

Meaning, you need a local smtp server to be set up in order to use the script.

like: 127.0.0.1

Edited by BackStabbed

tolle indicium

## 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

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...