Scripting Question

Im new to VBS and need help creating a fewscripts to find and delet efiles and or folders.

I'm new to VBS and need help creating several scripts. I'm trying to find and delete files and folders, I can do it if I know the path to the file or folder but I do not know the location of the files or folders.

Script #1 Search every folder/sub folder on C drive for a specific file, lets say "badfile.exe" and then delete it, pop up a message saying "badfile.exe deleted successfully" or "file not found".

Script #2 Search C drive for a folder, lets say "badfolder" then delete it and its content, pop up a message saying "badfolder deleted successfully" or "folder not found".

Script #3 Search C drive for a folder lets say "badprogram" then look for a file in that folder lets say "uninstall.exe" and run the file to uninstall the badprogram or pop up a message saying "file not found"

Comments

I assume there is suppose to be a box that pops up where I enter the file name to serch for and another to enterwhere I want it to start searching but it never pops up I get the following error on line

All Answers

Here's a generic script that shows some logic on scanning the drive. It's not exactly what you're asking for, but should get you started.

Plus, I learned most of my scripting by my good friend Google and typing "VBSCRIPT Delete file". Or something like that. There are a lot of examples out there for the "borrowing".

dig through this a while and see what you get.

After the MSGBOX at the bottom (Line 53) that says: "Found it..." you can put a "oFSO.DeleteFile File.Name" line. Just be warned, it will delete it without asking. You would have to put a question in there if you wanted to protect yourself.

I assume there is suppose to be a box that pops up where I enter the file name to search for and another to enter where I want it to start searching but they never pop up as I get the following error on line

Just go to computerperformance.com. There are scripts of every kind imaginable there. You probably won't ever find a single script that does everything you want but you can mix and match.

If I can offer some advice, though...

- Always assume the worst, i.e. that *nothing* will work and error-trap everything, even creating well-known objects.

- Find and use a logging class (don't be put off by that word - it's just a collection of functions and property gets/sets) so that logging your script's activity becomes second nature and not something you tack on to the end as an after-thought.

- Test *every* scenario, even those that "won't ever happen" because you can bet that one day, "never" comes around!

Share

This website uses cookies.
By continuing to use this site and/or clicking the "Accept" button you are providing consent
Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our
websites or when you do business with us. For more information about our
Privacy Policy and our data protection
efforts, please visit
GDPR-HQ