W
W
whatfor4772017-03-09 13:41:27
PowerShell
whatfor477, 2017-03-09 13:41:27

How to delete files from user desktops?

Tell me how to delete files from the user's desktop?
I wrote a batch file, but when I create a batch file in group policy and, roughly speaking, I upload this batch file, it does not work when the computer is turned off, and when I run the script separately, it gives.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Konstantin Tsvetkov, 2017-03-09
@tsklab

create in group policy
The GPO already has a whole branch of desktop management, including its lock.
d1f9624da28c4a6b8eb45d71bdeba793.png

D
Dmitry, 2017-03-09
@Tabletko

In which GPO branch did you specify the batch file? The user may not have permission to read it.
(hint!) And what if instead of deleting you prevent users from writing to the Desktop folder?

W
whatfor477, 2017-03-09
@whatfor477

I created a group in the forest, added users, and applied it to the computer and to user configurations. Maybe you need to create a script. What when turning off the computer, run this batch file?
Here is the batch file itself:
@Echo off
shutdown -a
Echo "Attention! The computer will be cleaned up now."
timeout 5 /NOBREAK
echo Search for files and folders.
2>nul (for /f "eol=: tokens=*" %%i in ('WHERE /F /RC:\Users\%username%\Desktop\ *.doc, *.xls, *.pdf, *. tiff, *.png, *.xml., *.cvs, *.git, *.rtf, *.bmp, *.jpeg, *.rar, *.zip, *.xmind') do del %%i)
echo Delete temporary system files.
del C:\Users\%username%\AppData\Local\Temp\* /S /Q
del C:\Users\%username%\Downloads\* /S /Q
del C:\Windows\Prefetch.
del C:\Windows\Temp. /Q
del C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Recent\* /S /Q
del /F /S /Q "C:\Users\%Username%\AppData\Local\Microsoft\ Windows\Temporary Internet Files\*"
shutdown -s -f -t 0
exit /b

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question