Search code examples
powershellscheduled-tasks

Scheduled task stays in execution


I have a scheduled task that sends a GMail with a subject, a body, and a file in it using an app called mailsend.-go.

This mail is sent using a script and the task executes every day at 7:00 AM.

When the task executes by itself at 7:00 AM or I do it manually, it stays in execution, and it doesn't work.

Here are the settings:

enter image description here

enter image description here

enter image description here

I tried to change some settings like adding arguments to the settings, and changing user settings.
I don't know if I'm forgetting something, but I need this, and I've been trying for days.

Here's the script:

# Directory containing Excel files
$directoryPath = "C:\Board\Dataset\Venda Diaria ASA\davidRibas.csv"

# Email address from which to send
$emailFrom = "no***@gb****.com"

# Email address to which it is sent
$emailTo = "da*****@ho*****.com"

# Mail subject
$subject = "Board - prova enviament venda diaria"

# Mail message
$messageToSend = "Cos del missatge - Us fem arribar una prova de l'enviament del fitxer de venda diaria"

# User
$user = "bo****@gb****.local"

# Password
$password = "*******"

# Comanda que s'executa per enviar el mail
mailsend-go -sub $subject -smtp smtp.gbassols.com -port 587 auth -user $user -pass $password -from $emailFrom -to $emailTo body -msg $messageToSend attach -file $directoryPath

Solution

  • The solution is just writing the path of "powershell.exe" in the program you want to execute and writing -command "pathOfTheScript" enter image description here