powershell and Scheduled Task

Welcome Forums General PowerShell Q&A powershell and Scheduled Task

Viewing 1 reply thread
  • Author
    Posts
    • #243086
      Participant
      Topics: 2
      Replies: 2
      Points: 17
      Rank: Member

      Good morning everyone, I have a small problem regarding a powershell script and scheduled operations.

      The script below should open a notepad process, send an email and close the newly opened process.

      If I do it step by step there are no problems everything works correctly if instead I try to insert it a scheduled operation I only get the notification email but the notepad window does not open let alone close.

      To do the tests I am using the notepad but this script should stop the running services, restart them automatically and send an email.

      [/crayon]

      Would anyone know how to make suggestions?

      The password used is fictitious and not the real password of the smpt server.

      As for the application to be run I used the notapad because it is the one that has a more immediate visual response.
      I don’t understand why the notepad app doesn’t open but the email is sent, being part of the same code.

      • This topic was modified 2 months, 1 week ago by Bruso7758.
      • This topic was modified 2 months, 1 week ago by Bruso7758.
    • #243098
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      Marco, welcome to Powershell.org. Please take a moment and read the very first post on top of the list of this forum: Read Me Before Posting! You’ll be Glad You Did!.

      When you post code, error messages, sample data or console output format it as code, please.
      In the “Text” view you can use the code tags “CODE“, in the “Visual” view you can use the format template “Preformatted“. You can go back edit your post and fix the formatting – you don’t have to create a new one.
      Thanks in advance.

      I’d recommend to use some other steps to “indicate” the progress of your script than opening an interactive application like notepad. You might write a file or output a sound for example.

      And it is not the best idea (actually a really bad idea) to place a password in your script. I hope you do just for testing purposes. You should run the scheduled task with the according account instead.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.