0

Wanting to know what language you would recommend. Have been talking to some friends and they recommended against CMD.

Basically I want to check %SystemRoot%\SYSTEM32\SPOOL\PRINTERS and see if there is any files older than 30 seconds or 1 minute. The physical number will be set. Then if it is delete the file.

If some one could guide me in the best way to program this that would be great :)

Matt Biggs
  • 169
  • 1
  • 3
  • 15
  • You can use batch script for your above purpose. Have a look at http://stackoverflow.com/questions/17785216/batch-script-to-delete-files-older-than-x-days-based-on-creation-date-not-modi – neo May 06 '14 at 07:54
  • create a batch file: http://stackoverflow.com/questions/20887130/batch-move-files-older-than-5-minutes – funk May 06 '14 at 07:56

1 Answers1

1

PowerShell is your friend. Part of your description is a little bit unclear, but here is what a script doing what I understand you want would resemble:

dir $env:SystemRoot\SYSTEM32\SPOOL\PRINTERS | 
where { ((get-date)-$_.creationTime).seconds -gt 30 } |
remove-item -force
David Brabant
  • 36,511
  • 13
  • 77
  • 101
  • Looks great. I am no wiz kid at PowerShell. What is the easiest way to get this to loop constantly? Just had a quick google of it and there are a few ways of doing it, though apparently you have to be careful of spirals – Matt Biggs May 06 '14 at 08:47