locked
Removing TMP files. RRS feed

  • Question

  • Hello everyone.. Hoping to get a little help from the more experienced. :)  

    We have this PS command to delete users temp folders - 

    Remove-Item -Path 'C:\Users\*\NS5\tmp' –Recurse

    We have been asked to complete this process by adding it to the end of an already used batch file.  Is it possible to change the above powershell command to a batch command and add it into a working script?  It can be ran at the end of the process or anywhere in between. 

    Hope this is clear, and thanks for the help!

    Thursday, February 12, 2015 7:38 PM

Answers

All replies

  • I think I'm reading your post correctly...

    In a batch file the command you're looking for should look like this:

    rmdir c:\users\*\nss\tmp /s /q


    • Edited by ThmsRynr Thursday, February 12, 2015 7:44 PM typo
    Thursday, February 12, 2015 7:44 PM
  • just running that line from the command prompt produces this error... any ideas?

    Thursday, February 12, 2015 7:59 PM
  • Is it possible to change the above powershell command to a batch command and add it into a working script?

    Basically, no. The reason is that the cmd.exe del command does not support wildcarded directory names within a path like PowerShell does.


    -- Bill Stewart [Bill_Stewart]

    Thursday, February 12, 2015 8:13 PM
  • At the end of your batch file:

    powershell -nonewwinow -command 'Remove-Item -Path C:\Users\*\NS5\tmp –Recurse'


    ¯\_(ツ)_/¯

    Thursday, February 12, 2015 8:28 PM
  • Is it possible to change the above powershell command to a batch command and add it into a working script?

    Basically, no. The reason is that the cmd.exe del command does not support wildcarded directory names within a path like PowerShell does.


    -- Bill Stewart [Bill_Stewart]

    Whoops, good catch. I haven't done much cmd.exe lately, all PowerShell.
    Thursday, February 12, 2015 8:43 PM
  • That will work, but it's not an example of changing a PowerShell command into an equivalent cmd.exe command. (There is no equivalent cmd.exe command.)


    -- Bill Stewart [Bill_Stewart]

    Thursday, February 12, 2015 8:43 PM
  • I appreciate all the feedback!  

    Looks like it may be just easier to setup a scheduled task using the powershell line mentioned above, rather than integrating into a batch file.  

    Thoughts?

    Thursday, February 12, 2015 8:56 PM
  • Thoughts about what?

    If you need disk cleanup, why not just use the built-in Windows tool?

    http://www.bing.com/search?q=cleanmgr


    -- Bill Stewart [Bill_Stewart]

    • Proposed as answer by jrv Thursday, February 12, 2015 9:25 PM
    • Marked as answer by Bill_Stewart Monday, March 16, 2015 4:59 PM
    Thursday, February 12, 2015 9:02 PM