Delete file scripting.filesystemobject
Its default value is False ; read-only files will not be deleted. FileSpec can contain wildcard characters as the final path component, which allows multiple files to be deleted. FileSpec can be a relative or absolute path.
If FileSpec specifies a path not ending in a path separator, the method will fail without generating an error. If you want to see what's going on, add WScript. Path right before the IsAccessible check. Note that you must run the script on the command line with cscript.
AutomatedChaos AutomatedChaos 7, 2 2 gold badges 24 24 silver badges 45 45 bronze badges. Care to comare the two solutions for performance?
The WMI solution took 0. Performance was only measured on the C: drive. I figured the WMI would be faster, but that difference is astonishing. Did you run them multiple times to compensate for the effect of Windows file system caching? AutomatedChaos Thank you for the answer. Where exactly I am suppose to to insert the name of the file I am looking for? I tried some alternatives but I either got an error or the script just ran and never returned anything.
I left it running for several minutes and nothing happened. It will only search your C: drive. If that works, you can create a more generic query over multiple drives. Filename can only be the real filename without extension, but I think you can figure out how to implement the extension in the query. To Test: create a testfile. Show 2 more comments.
Sign up or log in Sign up using Google. Sign up using Facebook. Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Is this page helpful? Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Skip to main content. This browser is no longer supported. Download Microsoft Edge More info.
0コメント