• Task Scheduler will not allow Display Message Tasks!

    Home » Forums » AskWoody support » Windows » Windows 8.1 » Questions: Win 8.1 (and Win 8) » Task Scheduler will not allow Display Message Tasks!

    Author
    Topic
    #501183

    I am trying to move from my old Vista laptop to my new Win8.1 laptop. I have a lot of scheduled tasks that simply display a reminder message about some specific that I should do. When I try to create a new task that displays a message in Win8.1 it displays “Deprecated” when I select Display a Message and when I try to save the task it will not save it! Why???

    How do I create tasks that will display messages for me?

    Thanks,
    Bill

    Viewing 23 reply threads
    Author
    Replies
    • #1517900

      Bill,

      These features have been removed from the task schedule in Win 8. Here’s an article on how to restore the feature using PowerShell with Task Scheduler. HTH :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      • #1518210

        These features have been removed from the task schedule in Win 8. Here’s an article on how to restore the feature using PowerShell with Task Scheduler. HTH :cheers:

        Well, the msg approach sounded very easy to implement so I have tried it for one message and so far I haven’t been able to get it to work! It should have displayed a message this morning and that didn’t happen so I’ve tried a number of things and nothing has worked so far. Do you know if the msg capability is in all versions of Win8? When I type msg in a command window I’m told it is unknown. Is the command window the right place to try it manually?

        Thanks,
        Bill

    • #1517911

      Thanks RG. That link you supplied provided the solution that should work on my laptop.

      Bill

    • #1517999

      I use UK’s Kalendar for that sort of thing, much easier than doing it manually.

      cheers, Paul

    • #1518239

      Bill,

      Ok, here’s my implementation of the article using PowerShell. Note the PS is a little longer than it has to be but I included some code to hide the main PS window for neatness.

      PowerShell Code: SchTaskMsgs.ps1

      Code:
      
      param (
              [Parameter(Mandatory=$true)]
                [String]$MsgTitle,
              [Parameter(Mandatory=$true)]
                [String]$MsgText
      )
      
      Add-Type -AssemblyName Microsoft.VisualBasic 
      
      # ----------------  add a helper  --------------------
      $showWindowAsync = Add-Type –memberDefinition @” 
      [DllImport("user32.dll")] 
      public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); 
      “@ -name “Win32ShowWindowAsync” -namespace Win32Functions –passThru
      
      function Show-PowerShell() { 
           [void]$showWindowAsync::ShowWindowAsync((Get-Process –id $pid).MainWindowHandle, 10) 
      }
      
      function Hide-PowerShell() { 
          [void]$showWindowAsync::ShowWindowAsync((Get-Process –id $pid).MainWindowHandle, 2) 
      }
      
      # ------------------ End Helper -------------------------------
      
      
      Clear-Host
      
      Hide-PowerShell
      
      $MsgBox = [Microsoft.VisualBasic.Interaction]
      
      [void] $MsgBox::MsgBox($MsgText,0,$MsgTitle)
      
      Show-PowerShell
      

      This is generic code so you can easily pass any message text and title to the routine.

      Here’s the Scheduled Task XML file which can be easily edited and renamed to change the messages:

      Code:
        
          DellXPS8700Bruce
          No Description Supplied
        
        
        
          
            DellXPS8700Bruce
            InteractiveToken
            LeastPrivilege
          
        
        
          IgnoreNew
          false
          false
          true
          false
          false
          
            false
            false
          
          true
          true
          false
          false
          false
          true
          false
          P3D
          7
        
        
          
            C:WindowsSystem32WindowsPowerShellv1.0powershell.exe
            [COLOR="#DDA0DD"]G:BEKDocsScripts[/COLOR]SchTaskMsgs.ps1 -MsgTitle[COLOR="#FF0000"] 'Test Msg'[/COLOR] -MsgText [COLOR="#FF0000"]'Beam Me Up Scottie!'[/COLOR]
          
        
      
      

      All you have to change are the two items in red and then save as a new name.xml and import into task scheduler.

      Note: The first time you edit the XML you’ll need to change the 2 references to DellXPS8700Bruce to your own MachineNameUserid. You’ll also have to change the DrivePath to the file.

      If you have never used PowerShell before read this thread posts #1 items 1-3:

      Sample Output:
      41505-scottie

      HTH :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      • #1520788

        Bill,

        Ok, here’s my implementation of the article using PowerShell. Note the PS is a little longer than it has to be but I included some code to hide the main PS window for neatness.

        PowerShell Code: SchTaskMsgs.ps1 . . .

        RG:

        I’m back on this subject again and I’ve decided to go with your suggested approach in your message earlier in this thread. I’m not completely clear on where I am to put the PowerShell script that you named SchTaskMsgs.ps1.

        Also, the outside article that you referenced earlier says this:

        When you open “Actions” tab, click on “New” button (or click on “Edit” button if you are editing the imported task) and type powershell in “Program/script” textbox and in “Add arguments” textbox paste following string:

        -WindowStyle hidden -Command “& {[System.Reflection.Assembly]::LoadWithPartialName(‘System.Windows.Forms’); [System.Windows.Forms.MessageBox]::Show(‘Your_Desired_Message’,’Your_Desired_Title’)}

        Do I use that in the Task Scheduler just as the outside article specified?

        Thanks,
        Bill

      • #1521509

        Sample Output:
        41505-scottie

        HTH :cheers:

        I keep seeing this RG and have to comment, sorry – No one ever said beam me up Scottie in TOS :flee:

        Eliminate spare time: start programming PowerShell

        • #1521659

          No one ever said beam me up Scottie in TOS

          But they should have!

          cheers, Paul

    • #1518426

      Thanks RG for the suggestion. I’ll try that for my stuff. The code windows show vertical scroll bars that indicate that some of the code is not visible in each case. Is this true or is it all there where I can do a copy and paste?

      Thanks,
      Bill

      • #1518427

        The code windows show vertical scroll bars that indicate that some of the code is not visible in each case. Is this true or is it all there where I can do a copy and paste?

        It’s visible if you scroll down. Or use the Select All button at the top.

    • #1520789

      Create the PS1 file and store it in a convenient location.
      Edit the XML as described. You need to change this bit to the location of your PS1 script: “G:BEKDocsScripts”
      Save the XML and then import it into Task Scheduler by clicking on “Task Library” and then “Import Task”.
      Edit the task as required.

      Don’t forget to allow PowerShell script execution.

      cheers, Paul

    • #1520835

      Thanks for setting me straight, Paul. I believe I am all set now.

      Bill

    • #1521501

      RetiredGeek, I have used your PowerShell code and task script above to get several reminder messages working on my new laptop. Thanks so much for the code routines.

      Do you know if there is any reasonable way to keep the PowerShell screen from occupying space on the taskbar? That would be desirable. Also, is there a way to make the new message open up as the active item so it will be immediately visible. I don’t necessarily want it to be forced to remain on top but just to be more visible when it first pops up.

      Thanks for your samples and help.
      Bill

      • #1521525

        RetiredGeek, I have used your PowerShell code and task script above to get several reminder messages working on my new laptop. Thanks so much for the code routines.

        You’re Welcome.

        Do you know if there is any reasonable way to keep the PowerShell screen from occupying space on the taskbar?

        Not that I’m aware of.

        That would be desirable. Also, is there a way to make the new message open up as the active item so it will be immediately visible.

        It always does on my machine. Of course, if you click somewhere else it will go to the back. Of course, that where having the PS icon on the task bar helps as it informs you there is something there to look at.

        Sorry I can’t be of more assistance. :cheers:

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

    • #1521548

      Thanks RG!

      Bill

    • #1522481

      A couple more questions about Power Shell. I tried to look this up online but was unsuccessful.

      1. Is there a way to embed a new-line character in the text string that is to be displayed in the message box so that the result is a two-line message even though it is treated as all one line in the line in the script?

      2. Can the power shell window, which is supposed to be invisible most of the time, be minimized? On my laptop, when I sign-in to my account if there are any messages that need to be displayed immediately they will open the power shell window and it will remain on the screen for many seconds because the computer is so busy right at that time.

      I’ll appreciate any help that is available!
      Bill

    • #1522484

      Bill,

      The answer to #1 is: `n

      As for #2 I’m already hiding the PS window and the MsgBox doesn’t have a setting to minimize. I’ll look into it further but don’t hold much hope for an easy solution so I could take some time but it would seem to defeat the whole purpose which is to get your attention?

      HTH :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #1522526

      Thanks RG for the help again. In order to put the ‘n in the middle of the text string I changed the enclosing quotes for the string from the single ‘ to the regular quote (“). Then I put the ‘n in the desired place. Full disclosure: I am actually after a 4 line message so I have the double quote at the beginning and end of the long string and the ‘n codes inserted at 3 places inside the string.

      The problem is the Power Shell window pops up and several lines of text are written on that window and then it closes. It is open for only a fraction of a second and I have tried several things and have not been able to get that window to stay open. I have carefully examined the message string and corrected a couple of mistakes along the way and nothing has corrected the problem or kept the window open.

      Do you have any suggestions?

      Thanks,
      Bill

    • #1522529

      Bill,

      I think you missed why I put the thing in BIG BLUE print it is not a Single Quote but rather that crazy back quote (above the Tab key on the same key as the ~). There is no need to change the quotes around your string at all! HTH :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #1522598

      Ooops! I knew there was a different, backwards, single quote and I wondered if that was what you were using but I didn’t remember that it is actually on the keyboard! So, I just went with the normal single quote. After making these changes and checking it carefully the Power Shell is still aborting but the number of lines written to the screen is much fewer. I still can’t read it so I’m going to download a screen recorder and record a video and then see if I can pause it at the right time to read the screen. I’ll get back to you when I get this done.

      Thanks,
      Bill

    • #1522606

      Bill,

      Just paste the PS between [noparse][/noparse] your code here [noparse][/code][/noparse] tags. Then do the same for the Scheduled Task after exporting it to xml. HTH :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #1522850

      OK RG. There aren’t any code and /code (don’t know how to include the [] without having the forum software use them!) key words in either one so I’m going to attach the entire Power Shell routine and the part of the task script that I think you have in mind. BTW, I did manage to use a video recorder to read the error message last night but didn’t take time to research it further before going to bed. The error message says “The string is missing the terminator”. There are other details after that but it does not identify the problem string in any way. I might be able to send the whole error message to you but I haven’t figured out how yet! I tried copy and paste and that didn’t work.

      First, the separate Power Shell routine is attached. I don’t believe I have changed it from what you gave me.

      Second are a few lines from the task script:

      C:WindowsSystem32WindowsPowerShellv1.0powershell.exe
      C:UsersBillWilsonSavedTasksPowerShellScriptsSchTaskMsgs.ps1 -MsgTitle ‘Get Credit Reports’ -MsgText ‘www.annualcreditreport.com `n Equifax http://www.investigate.equifax.com `n …Experian http://www.experian.com `n TransUnion http://www.transunion.com

      I hope those are the parts that you had in mind. BTW, I see that I missed the url & /url around the first URL. I’ll fix that and let you know if that fixes the problem.

      Thanks for your help.
      Bill

    • #1522919

      Bill,

      Ok, I’ve been working on this for the last 90 minutes and I’m somewhat at a loss. Here’s what I do know.

        [*]Powershell treats single quotes ‘ ‘ differently than double quotes ” “.

        [*]Items between single quotes are NOT interpreted, thus, having the `n between single quotes will actually print the `n in the message. BTW: The script does work in that mode when called from the task scheduler.

        [*]Items between double quotes will be interpreted for variable substitution and escape character (`) processing. However, If I substitute double quotes around the message it generates errors when called from the task scheduler! The script works properly with the double quotes if called from a PowerShell window directly!

        [*]Currently, I’m stumped as to seeing what the error messages are as the script won’t halt long enough for me to read them despite trying every debugging trick I know such as $ErrorActionPreference =”Inquire”; $x = Read-Host -Prompt “Press Any Key”; and redirection to a file via Try/Catch.

      Maybe some of the PS experts out there can provide some ideas?

      I’ll keep working but I wanted you to know what I’ve done so far. :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #1522937

      Thanks for the effort RG. I’ll wait to see if anyone else chimes in with a good idea. I am inclined to look for a different approach for this periodic reminder related to getting my credit reports periodically. You have put in a lot of time on my behalf and I don’t want to take up too much of your time, so I appreciate what you have done and will be happy even if you call it quits at this point.

      Thanks,
      Bill

    • #1522971

      Bill,

      What you may want to consider is setting up 3 different task messages one for each reporting entity spaced 4 months apart. Then you can do it with single quotes w/o the line feed chars. I have it in my Outlook calendar to remind me but what I do is get it from a different one each 4th month. That way I have basic continuous monitoring and don’t have to pay for a service. HTH :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #1522974

      Yes I have the same objective and on my old laptop I used the multiline message and moved the pointer along each time so I would know which one to contact the next time. I’ll go ahead and set up the 3 messages and get past this problem.

      Bill

    • #1523086

      Bill,

      Glad you could get past it…however, I couldn’t! 😆

      So I’ve figured out how to make this work. You MUST use single quotes in the Task Scheduler Action Arguments! I’ve adjusted the code to allow for this and replace the newline & also tab characters with the appropriate expanded character.

      Here’s the new code:

      Code:
      
      param (
              [Parameter(Mandatory=$true)]
                [String]$MsgTitle,
              [Parameter(Mandatory=$true)]
                [String]$MsgText
      )
      
      Add-Type -AssemblyName Microsoft.VisualBasic 
      
      # ----------------  add a helper  --------------------
      $showWindowAsync = Add-Type –memberDefinition @” 
      [DllImport("user32.dll")] 
      public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); 
      “@ -name “Win32ShowWindowAsync” -namespace Win32Functions –passThru
      
      function Show-PowerShell() { 
           [void]$showWindowAsync::ShowWindowAsync((Get-Process –id $pid).MainWindowHandle, 10) 
      }
      
      function Hide-PowerShell() { 
          [void]$showWindowAsync::ShowWindowAsync((Get-Process –id $pid).MainWindowHandle, 2) 
      }
      
      # ------------------ End Helper -------------------------------
      
      Clear-Host
      
      Hide-PowerShell
      
      $MsgBox = [Microsoft.VisualBasic.Interaction]
      
      $MsgText = $MsgText -replace '`n',"`n"  #Fix single quoted string new lines!
      $MsgText = $MsgText -replace '`t',"`t"  #Fix single quoted string tab chars!
      
      [void] $MsgBox::MsgBox($MsgText,0,$MsgTitle)
      
      Show-PowerShell
      

      And your desired message:
      41731-BillWilson

      Note: Don’t know where I picked up the … before Experian but they are in the task scheduler message and thus displayed.

      HTH :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #1523221

      Well you are very persistent! 🙂 That’s great! I haven’t had a chance today to update to your new code but I will tomorrow. This single message approach does have one advantage for me — I am not very quick to react to some of my reminders like this and with a separate message for each agency the reminder would likely appear on a fixed date for each one. That could possibly lead to applying to an agency twice in less than a year and that might complicate things. With the single reminder message I always schedule the next one 4 months from the date when I actually send in a request so that keeps the spacing on the safe side. BTW, the “…” beside one name was a temporary pointer to the one that was to be requested next. In my old Vista version I used “>” as the pointer but I took that out and changed temporarily to “…” to prevent any conceivable confusion when we were having the failures. My practice has been to edit the message each time it comes up to move the pointer to the next name. Thanks for sticking with this!

      Bill

    • #1523523

      RG, I used your revised Power Shell code in place of the one I have been using. I still get a Power Shell error about a missing string terminator. Can you post the Arguments section of your Task code so I can be sure I have everything you used to get the successful result?

      Thanks,
      Bill

    • #1523524

      Bill,

      Here it is:

      Code:
            C:WindowsSystem32WindowsPowerShellv1.0powershell.exe
            G:BEKDocsScriptsSchTaskMsgs.ps1  -MsgTitle 'Get Credit Reports' -MsgText 'www.annualcreditreport.com`nEquifax www.investigate.equifax.com`n...Experian www.experian.com`nTransUnion www.transunion.com'
          
      

      Note: the above is from the exported task .xml file.

      HTH :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      • #1523559

        Yippee! Now it works with the 4-line message! I would never have gotten here on my own so I really appreciate your effort on this.

        Thanks,
        Bill

        PS: I don’t know why my latest version failed but one difference between yours and mine was that I still had some blank spaces between the individual texts for each line and yours does not. There was no reason for the spaces and it looks good and works now.

    Viewing 23 reply threads
    Reply To: Task Scheduler will not allow Display Message Tasks!

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: