none
Microsoft schedule not working with script with env PATH RRS feed

  • Question

  • I need clear directory via schedule, but I have a promblem: if path to my direcotry not hard - it will not work.

    Example: this way wrong

    #Script path
    $scriptPath = "$HOME\.erasecache"

    $cacheFolder = "$scriptPath\cache"

    Remove-Item -Recurse -Force $cacheFolder\*


    Example: this will working fine

    #Script path
    $scriptPath = "$HOME\.erasecache"

    $cacheFolder = "$scriptPath\cache"

    Remove-Item -Recurse -Force C:\cache\*

    How do I can fix schedule for working with variable path or with env: path?

    Powershell 5.1

    Windows 10 Home x64

    • Moved by jrv Monday, April 30, 2018 3:29 AM
    Saturday, April 7, 2018 1:39 PM

All replies

  • Please DO NOT post colorized code.

    Post code using the code posting tool provided on the edit tool bar.

    Do not write code split across two lines.  Single statements should be on one line except when you understand how PowerShell works.

    Please fix your original post before you ask any more questions.


    \_(ツ)_/

    Saturday, April 7, 2018 2:14 PM
  • Please DO NOT post colorized code.

    Post code using the code posting tool provided on the edit tool bar.

    Do not write code split across two lines.  Single statements should be on one line except when you understand how PowerShell works.

    Please fix your original post before you ask any more questions.


    \_(ツ)_/

    I am so sorry, I cant delete this topic, how can I do it?
    Saturday, April 7, 2018 2:43 PM
  • Just edit the original post.  The edit button is above the post.


    \_(ツ)_/

    Saturday, April 7, 2018 2:45 PM
  • Or put a <pre> tag in front of the first <div>.

    Saturday, April 7, 2018 3:17 PM
  • Or put a <pre> tag in front of the first <div>.

    That does NOT produce readable output in all browsers and depends on which site you are posting through.  These forums have many possible "skins" and many will only display trash if you post HTML colorized code.

    The code posting tool will strip all html tags from the pasted code and use the sites CSS to colorized code according to the selected language.

    The bigger issue is, if we want to copy the code posted, the copy will include the HTML and will paste in almost any editor as broken code.  This is why the code posting tool is included in the editor.  It makes copying code produce a correct plain text copy with no HTML.


    \_(ツ)_/

    Saturday, April 7, 2018 3:33 PM
  • Remove-Item "$cacheFolder\*" -Recurse -Force


    Monday, April 9, 2018 8:00 AM