I've written a script for a school I'm working at to automatically mount a folder as drive
X: and then to go into drive
X and recursively scan all folders and sub folders for
.vbs files and delete them. The script works almost perfectly. My problem is that if there are any errors (e.g., a drive path is too long), it will not log it to a text file. Is there any way this can be done with a batch file?
@echo off net use X: \\NETWORK PATH HERE X: cls Echo Deleting bat files please wait... del /s *.bat > DeletedFiles.txt Echo Deleting CMD files please wait... del /s *.cmd >> DeletedFiles.txt Echo Deleting VBS files please wait... del /s *.vbs >> DeletedFiles.txt Echo Deleting Executable files please wait... del /s *.exe >> DeletedFiles.txt Echo Process Completed set /p=Press Any Key To Close
Currently any errors I have to (manually) read from the CMD window and sort out. It would be handy to have all errors and deleted files saved to a text file for record keeping purposes.
Also PowerShell is out of the question; despite being a system admin, the education department will not give me rights to run PowerShell or VBS scripts.