Delete AUC and KTI files for all users

We run Microsoft Dynamics AX 2012. We have Remote Desktop Servers which users access, to access AX.

I'd like a PS script or bat file that I can run once a week, at midnight, to delete *.AUC and *.KTI files from all the users C:\users\%users%\appdata\local   folder on these RDS machines.

I've tried
for /D %D in ("C:\USERS\*") do del "%~fD\AppData\Local\*.auc"
for /D %D in ("C:\USERS\*") do del "%~fD\AppData\Local\*.kti"

Which Errors out:
The following usage of the path operator in batch-parameter substitution is invalid: "%~fD\AppData\Local\*.auc"

Also tried:
del "%userprofile%\AppData\Local\*.auc"
del "%userprofile%\AppData\Local\*.kti"

But that only delete the files for the current user.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Inside a batch script, you need to use double percent signs for the loop variable
for /D %%D in ("C:\USERS\*") do del "%%~fD\AppData\Local\*.auc"
for /D %%D in ("C:\USERS\*") do del "%%~fD\AppData\Local\*.kti"

Open in new window

PowerShell in test mode; will only show the files it would delete; remove the -WhatIf at the end of line 3 to run it for real:
Get-ChildItem -Path C:\Users -Directory | ForEach-Object {
	ForEach ($ext in 'auc', 'kti') {
		Get-ChildItem -Path  "$($_.FullName)\AppData\Local" -File -Filter *.$ext -ErrorAction SilentlyContinue | Remove-Item -WhatIf

Open in new window

pdesjardins1Author Commented:
Your batch script work.
Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.