FN-GM Posted December 22, 2007 Report Posted December 22, 2007 How do I delete a folder using a script, how easy is it please as i am not a script expert. Thanks Z
mac_shinobi Posted December 22, 2007 Report Posted December 22, 2007 http://www.tutorial-web.com/asp/fso/folder.asp?property=Delete http://www.devx.com/vb2themax/Tip/18643 vbscript btw also what exactly are you trying to do
mattx Posted December 22, 2007 Report Posted December 22, 2007 Type in on a command line DEL /? and RMDIR /? Or AutoITs DirRemove. ; Delete C:\Test1 and all subdirs and files DirRemove("C:\Test1", 1)
FN-GM Posted December 22, 2007 Author Report Posted December 22, 2007 Hi I am trying to remove things from the start menu that are not need. @mattx thanks for that, is that a VBS or BAT script please? Thanks
mac_shinobi Posted December 22, 2007 Report Posted December 22, 2007 The script is an auto it script , the commands he posted before that are from command line. Depends what you want to do, I mean you could put the command line commands into a bat file.
arran Posted December 22, 2007 Report Posted December 22, 2007 //JScript var fso; fso = new ActiveXObject("Scripting.FileSystemObject"); fso.DeleteFolder("C:\\foldername"); 'VBScript Dim fso Set fso = CreateObject("Scripting.FileSystemObject") fso.DeleteFolder("C:\\foldername") Code from JScript5.chm and Vbscrip5.chm Edit: Sorry guys, vbscript uses one slash and JScript uses two slashes. JScript uses two slashes as the first slash is used to denote an escaped character such as \n \r \t etc where as vbscript use vbCr vbLf vbTab and so on.
mac_shinobi Posted December 22, 2007 Report Posted December 22, 2007 //JScript var fso; fso = new ActiveXObject("Scripting.FileSystemObject"); fso.DeleteFolder("C:\\foldername"); 'VBScript Dim fso Set fso = CreateObject("Scripting.FileSystemObject") fso.DeleteFolder("C:\\foldername") Code from JScript5.chm and Vbscrip5.chm Bit of a daft question but I have always seem some code snippets in delete or copy files or folders with one slash ie \ and others with 2 ie \\ such as this : //JScript var fso; fso = new ActiveXObject("Scripting.FileSystemObject"); fso.DeleteFolder("C:\\foldername"); 'VBScript Dim fso Set fso = CreateObject("Scripting.FileSystemObject") fso.DeleteFolder("C:\\foldername") '<-- in the directory path there is \\ Just wanted to know what difference does it make ?
K.C.Leblanc Posted December 22, 2007 Report Posted December 22, 2007 There's a freeware prog called orphan remover that scans the start menu for dead shortcuts and removes them. It can be ran in a quiet mode from a script. Where I used to work for had student accounts set up not to process the all users profile instead all the shortcuts came from the students mandatory profile. We then had orphan remove set to kill the shortcuts for any progs that weren't installed on that particular machine.
ChrisH Posted December 22, 2007 Report Posted December 22, 2007 Have a look on the microsoft scripting site. There a plenty of snippets on there you can play around with and put together to make your own scripts. If you look under the sticky in the scripting section you will also see a few programs that will create basic scripts for you.
FN-GM Posted December 22, 2007 Author Report Posted December 22, 2007 Thanks guys i ended up using this 'VBScript Dim fso Set fso = CreateObject("Scripting.FileSystemObject") fso.DeleteFolder("C:\\foldername") Z
FN-GM Posted December 22, 2007 Author Report Posted December 22, 2007 Using this code 'VBScript Dim fso Set fso = CreateObject("Scripting.FileSystemObject") fso.DeleteFolder("C:\\Documents and Settings\All Users\Start Menu\Programs\folder1") fso.DeleteFolder("C:\\Documents and Settings\All Users\Start Menu\Programs\folder t2") When the folder does not exist i get the following message, any ideas please?
maniac Posted December 22, 2007 Report Posted December 22, 2007 stick On Error Resume Next at the start of your script, that will ignore any errors thay occur when it runs. Mike.
ChrisH Posted December 22, 2007 Report Posted December 22, 2007 stick On Error Resume Next at the start of your script, that will ignore any errors thay occur when it runs. Mike. Thats the easy way but the correct way would be to check if the folder exists then try and delete it else do nothing.
ITWombat Posted December 22, 2007 Report Posted December 22, 2007 I suspect that the problem is with the double back slash in the VBS. I don't recall having to use it in leteral path references. Now JScript with its nod to its Java/Unix roots uses // because a single forward slash in a quoted string normally introduces control characters.
maniac Posted December 22, 2007 Report Posted December 22, 2007 stick On Error Resume Next at the start of your script, that will ignore any errors thay occur when it runs. Mike. Thats the easy way but the correct way would be to check if the folder exists then try and delete it else do nothing. You are indeed correct! (but I'm always one for the easy option.) My VBS coding skills are limited! Mike.
FN-GM Posted December 22, 2007 Author Report Posted December 22, 2007 works perfectly now, thanks guys Z
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now