Hi, I have a folder (say "Humm") that may be under any user in c:\Documents and Settings. I am looking for a script that searches for this folder and then deletes it.

I have searched the web but can't find one. Any ideas?

Thanks,

Mike.
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Community Chosen Answer

4
OK, see if this works for you - it's an adaptation of the code found in this article


' Sample VB Script to remove the folder "Hmmm" (plus any contents) located in the profile folder for every user on the
' system.
'
' Alter the constant, FolderToDelete, to meet your own requirements
'
Const FolderToDelete = "\Hmmm"
Const AllUsers = "\All Users"

Dim strComputer
Dim oWMI, oWSH, oFSO
Dim sAllUsersProfile, oAllUsersFolder, sProfilesRoot, oFolder
Dim colFSOSubFolders, colWMISubFolders, colSubFolders, colSubFolders2
Dim intSize
Dim objFolder, objFolder2, objSubFolder
Dim strFolder, strFolderName

' Instantiate the various objects

strComputer = "."
Set oWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set oWSH = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")


' Get the Allusers profile folder path first and from this determine profiles parent folder
'

sAllUsersProfile = oWSH.ExpandEnvironmentStrings("%ALLUSERSPROFILE%")
Set oAllUsersFolder = oFSO.GetFolder(sAllUsersProfile)
sProfilesRoot = oAllUsersFOlder.ParentFolder

' Now enumerate all existing user profile folders

Set oFolder = oFSO.GetFolder(sProfilesRoot)
Set colFSOSubfolders = oFolder.Subfolders

' Now go through each existing user profile folder looking for the designated folder to delete

For Each objSubfolder in colFSOSubfolders

if oFSO.FolderExists(sProfilesRoot & "\" & objSubfolder.Name & FolderToDelete) then
intSize = 0
strFolderName = sProfilesRoot & "\" & objSubfolder.Name & FolderToDelete

Set colSubfolders = oWMI.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")

ReDim Preserve arrFolders(intSize)
arrFolders(intSize) = strFolderName
intSize = intSize + 1

For Each objFolder in colSubfolders
GetSubFolders strFolderName
Next
For i = Ubound(arrFolders) to 0 Step -1
strFolder = arrFolders(i)
strFolder = Replace(strFolder, "\", "\\")
Set colFolders = oWMI.ExecQuery _
("Select * from Win32_Directory where Name = '" & strFolder & "'")

For Each objFolder in colFolders
errResults = objFolder.Delete
Next
Next
end if
Next


' ***************************************************************************************************************
Sub GetSubFolders(strFolderName)
Set colSubfolders2 = oWMI.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")

For Each objFolder2 in colSubfolders2
strFolderName = objFolder2.Name
ReDim Preserve arrFolders(intSize)
arrFolders(intSize) = strFolderName
intSize = intSize + 1
GetSubFolders strFolderName
Next
End Sub

' ****************************************************************************************************************


Regards,

Spartacus
Answered 09/12/2006 by: spartacus
Black Belt

Please log in to comment
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Thanks Spartacus - appreciate you taking time to reply. Working on something else today but will hopefuly have time later to try it out - will late you know how I get on - thanks again!
Answered 09/13/2006 by: Meic
Second Degree Blue Belt

Please log in to comment
0
Spartacus - that script worked a treat - thanks very much. Mike.
Answered 09/21/2006 by: Meic
Second Degree Blue Belt

Please log in to comment
0
Hi Spartacus,

Your script works great, bt maybr I didn't explain things clearly enough.

As I don't know whose profile the "Humm" folder may be in - I need it to search every users profile in Docs & Settings.i.e. I need it to search every sub folder of Docs and Settings. I have tried changing:

Const AllUsers = "\All Users"

to something like:

Const AllUsers ="\Documents and Settings"

but it doesn't delete the folder. Any ideas wht else I should change?

Thanks,

Mike.
Answered 09/29/2006 by: Meic
Second Degree Blue Belt

Please log in to comment
2
the script must be kept after installfinalize and condition must be REMOVE
it will forcefully remove the folder, so all the files and the folders will be removed


'==========================================================================
Option Explicit
On Error Resume Next
'==========================================================================
'
' DESCRIPTION: To append the environment variable.
'
' NAME: delete_folder.vbs
'
'
' AUTHOR: Jimmy Antony
' DATE: 01/10/2006

' USAGE: To delete the folder "Humm" which is present any where in C:\Documents and Settings
'
' SEQUENCE: After installfinalize
'
'
' NOTE: This script will remove the folder forcefully
'
'==========================================================================
ShowFolderList("C:\Documents and Settings")
Function ShowFolderList(folderspec)
Dim fso, f, f1, s, sf
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 in sf
ShowFolderList(f1.path)
if strcomp(f1.name,"Humm") = 0 then
fso.deletefolder f1.path, true
Exit for
Exit function
End if
Next

End Function
'==========================================================================
Answered 09/30/2006 by: jimmy.alappatt
Senior Yellow Belt

Please log in to comment
0
Thanks for your reply Jimmy - works great as well.
Answered 10/06/2006 by: Meic
Second Degree Blue Belt

Please log in to comment
0
Hi, this one removes all patch uninstall directory from Windows Folder.
As i readed in the Forums the folder "$hf_mig$" should not be deleted.

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set OFWindows = oFSO.GetFolder("c:\windows")
Set OWinFolders = OFWindows.SubFolders
For Each OWinFolder in OWinFolders
if Ucase(left(OWinFolder.name , 14)) = "$NTUNINSTALLKB" then OWinFolder.delete force
Next


Miro
Answered 11/28/2006 by: Miro
Senior Yellow Belt

Please log in to comment
0
The script Spartacus has works great however I need to delete 2 folders from every users profile and not just one. how would I edit the script to do that?
Answered 09/26/2008 by: taz081175
Senior Yellow Belt

Please log in to comment
0
Set the folder names as an array and loop through that array, passing the name to the delete part. Easy.
Answered 09/26/2008 by: VBScab
Red Belt

Please log in to comment
0
Sorry VBScab, but I am new to VB. Any chance you could show me an example please?
Answered 09/26/2008 by: taz081175
Senior Yellow Belt

Please log in to comment
0
VBScab means something like this (test it first):

' Sample VB Script to remove the folder "Hmmm" (plus any contents) located in the profile folder for every user on the
' system.
'

'define your folders in an array
Dim folders(3)
folders(0) = "folder1"
folders(1) = "folder2"
folders(2) = "folder3"
folders(3) = "folder4"


Const AllUsers = "\All Users"
Dim strComputer
Dim oWMI, oWSH, oFSO
Dim sAllUsersProfile, oAllUsersFolder, sProfilesRoot, oFolder
Dim colFSOSubFolders, colWMISubFolders, colSubFolders, colSubFolders2
Dim intSize
Dim objFolder, objFolder2, objSubFolder
Dim strFolder, strFolderName
' Instantiate the various objects
strComputer = "."
Set oWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set oWSH = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")

' Get the Allusers profile folder path first and from this determine profiles parent folder
'
sAllUsersProfile = oWSH.ExpandEnvironmentStrings("%ALLUSERSPROFILE%")
Set oAllUsersFolder = oFSO.GetFolder(sAllUsersProfile)
sProfilesRoot = oAllUsersFOlder.ParentFolder
' Now enumerate all existing user profile folders
Set oFolder = oFSO.GetFolder(sProfilesRoot)
Set colFSOSubfolders = oFolder.Subfolders
' Now go through each existing user profile folder looking for the designated folder to delete
For Each foldername In folders 'loop through your folder names
For Each objSubfolder in colFSOSubFolders

If oFSO.FolderExists(sProfilesRoot & "\" & objSubfolder.Name & "\" & foldername) then
intSize = 0
strFolderName = sProfilesRoot & "\" & objSubfolder.Name & "\" & foldername

Set colSubFolders = oWMI.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")

ReDim Preserve arrFolders(intSize)
arrFolders(intSize) = strFolderName
intSize = intSize + 1

For Each objFolder in colSubfolders
GetSubFolders strFolderName
Next
For i = Ubound(arrFolders) to 0 Step -1
strFolder = arrFolders(i)
strFolder = Replace(strFolder, "\", "\\")
Set colFolders = oWMI.ExecQuery _
("Select * from Win32_Directory where Name = '" & strFolder & "'")

For Each objFolder in colFolders
errResults = objFolder.Delete
Next
Next
end If
Next
Next

' ***************************************************************************************************************
Sub GetSubFolders(strFolderName)
Set colSubfolders2 = oWMI.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")
For Each objFolder2 in colSubfolders2
strFolderName = objFolder2.Name
ReDim Preserve arrFolders(intSize)
arrFolders(intSize) = strFolderName
intSize = intSize + 1
GetSubFolders strFolderName
Next
End Sub
' ****************************************************************************************************************
Answered 09/26/2008 by: captain_planet
Second Degree Brown Belt

Please log in to comment
0
Thanks captain_planet. it worked like a charm
Answered 09/26/2008 by: taz081175
Senior Yellow Belt

Please log in to comment
0
Hi guys, what about if you need to delete a folder in the root of C:\ Example C:\roma70\test\Test.ini
I would like to be able to remove files and folders.
Any help really appreciated.

Thanks
Also do you know any Vbs book for newby?
Answered 12/18/2008 by: roma70
Senior Yellow Belt

Please log in to comment
0
Hi guys, what about if you need to delete a folder in the root of C:\ Example C:\roma70\test\Test.ini
I would like to be able to remove files and folders.
Try this. It's particularly brutal, in that it has the 'Force' flag for the folder deletion, i.e. it will delete it, even if the folder has content. There's no reason why you couldn't add in code to check for file content, though.Option Explicit

Dim strFolderTree
Dim objFSO
Dim blnResult
strFolderTree = "C:\Level1\Level2\Level3\Level4"

Set objFSO = CreateObject("Scripting.FileSystemObject")

blnResult = CreateFolderTree(strFolderTree)

blnResult = DeleteFolderTree("C:\Level1")

Set objFSO = Nothing

Function CreateFolderTree(ByVal strFolderPath)
CreateFolderTree = False

With objFSO
If Not .FolderExists(strFolderPath) Then
If CreateFolderTree(.GetParentFolderName(strFolderPath)) Then
CreateFolderTree = True
Call .CreateFolder(strFolderPath)
End If
Else
CreateFolderTree = True
End If
End With
End Function

Function DeleteFolderTree(ByVal strPath)

Dim objFolder

With objFSO
'// Enumerate the sub-folders in the folder we've been given.
For Each objFolder In .GetFolder(strPath).SubFolders
DeleteFolderTree(objFolder.Path)
Next

'// Now that the folder we've been given is empty, we can delete it
.DeleteFolder(strPath), True
End With
End Function

Also do you know any Vbs book for newby? Books, schmooks...the best way to learn is to d/l scripts and use them, then edit to suit your requirements. There's a handy reference here http://www.devguru.com/technologies/vbscript/home.asp, LOADS of good (and plenty of bad!) examples here http://cwashington.netreach.net and also at

http://www.cruto.com/resources/vbscript/vbscript-examples/vbscript-sitemap.asp
http://www.computerperformance.co.uk/vbscript/index.htm
http://www.thescriptlibrary.com/Default.asp?Action=SubIndex&ScriptLanguage=VBScript
Answered 12/18/2008 by: VBScab
Red Belt

Please log in to comment
0
On Error Resume Next
CreateObject("Scripting.FileSystemObject").DeleteFolder "Give Path Here", True

Regards,
Khwaja Moin
Answered 12/18/2008 by: moinkm5
Yellow Belt

Please log in to comment
0
Thanks guys, I did find something that suit my need on the Scripting Guy, thanks for you time I will keep those scripts in mind for future need
Answered 12/20/2008 by: roma70
Senior Yellow Belt

Please log in to comment
0
ORIGINAL: roma70
Thanks guys, I did find something that suit my need on the Scripting Guy, thanks for you time I will keep those scripts in mind for future need

Glad you did! I've found them to be a great resource and it keeps me from bugging folks here too much :-) seriously, give props (ratings) to those who helped you.
Answered 12/20/2008 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
0
Hi Spartacus, I'm kind of having the same issue as Meic.
I'm trying to remove Microsoft Office Shortcuts from all users profiles.
how can i modify the script that you posted to search for shortcuts\file instead of a folder?
for example
Microsoft Office excel 2003
Microsoft Office Word 2003

Any help will be appreciated.
Answered 07/08/2010 by: u_larin812731
Yellow Belt

Please log in to comment
0
here is something i used to delete outlook shortcuts. modify it for whatever yours are named. and gimme some rating points if it works for ya! :-)

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_DataFile where Name = 'Microsoft Office Outlook 2003' AND Extension = 'lnk'")
For Each objFile in colFiles
objFile.Delete
Next
Answered 07/08/2010 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
0
this is why i rarely visit any more
most of these folks just take, and don't even say thank you.
Answered 07/15/2010 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
0
You're right, of course, Owen, in general terms but can you guarantee that the poster used - or even saw- your script? He may have found a solution elsewhere and never came back here to check if his post was answered.
Answered 07/16/2010 by: VBScab
Red Belt

Please log in to comment
0
Funny how that works, isn't it? I've gotten points for some really weird posts I didn't think were all that helpful, then nothing when I go way out of my way to write up some incredibly detailed analysis.

Fortunately the rating system is more or less meaningless here, so I don't worry about it too much.
Answered 07/16/2010 by: Jsaylor
Second Degree Blue Belt

Please log in to comment
0
Sorry for the delay guys but, I had an emergency and had to go for two weeks.
Unfortunately your script did not work but, I think I know why Im having this issue.
There is only one user (test) account that leaves left overs and I'm trying to figure out why.
If I log on as another user all shorcuts get deleted, most likely is a problem with this account
I appreciate all your help though.
Answered 07/21/2010 by: u_larin812731
Yellow Belt

Please log in to comment
0
In all likelihood, this will be a permissions issue. I suspect that the user's rights to write and/or delete files and/or folders in his profile are broken in some way.
Answered 07/21/2010 by: VBScab
Red Belt

Please log in to comment
0
hi was hoping someone could help - read the forum and want to do the following:
Run VB script to check for the presence of file99.ini in c:\Documents and Settings\%username%\Application Data\FileX\ and delete it.

Help much appreciated.
Answered 08/11/2010 by: NewtotheVB
Yellow Belt

Please log in to comment
0
There must be a quadzillion examples of scripts like this around. Start here at AppDeploy and search for 'www.computerperformance'. That will turn up a heap of posts with other links to VBScript sites, one of which will have something similar to what you want.

Some words of advice:

- avoid hard-coding stuff like 'C:\Documents and Settings'. That restricts the script's "ageing" capability (meaning that it will fail on Vista/Windows 7, for example). Instead, get as far down the path as you can using data which is available to you. In this case, that will be the 'Application Data' folder which can be divined from an environment variable.

- error-trap EVERYTHING. Assume nothing will work, including declaration of objects, even ones "which will always work" like FileSystemObject.
Answered 08/12/2010 by: VBScab
Red Belt

Please log in to comment
0
the script definitely works if your syntax, shortcut names are correct, and there are no permissions issues. I've used it myself in production.
Answered 09/14/2010 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
0
Hi, I'm trying to take spartacus' example but apply it to a Vista / 7 environment.
In my case, I'm looking at deleting a folder under C:\Users\{username}\AppData\Roaming
I tried replacing %ALLUSERSPROFILE% with %APPDATA%...
I'm also unsure what to do with the constant AllUsers...

Any help would be much appreciated!
Answered 11/04/2010 by: QueBusQuoi
Yellow Belt

Please log in to comment
0
So I hope you guys are still reading these posts. I am trying to do the above but I need a single script regardless if it is XP or Win7. How would I modify this script to search for the folder? For instance on Windows 7 the location is:
c:\users\%username%\Appdata\locallow\sun\java\deployment\cache\6.0

but for XP is is:
c:\documents and settings\%username%\Application data\sun\java\deployment\cache\6.0

My guys want to push this via SCCM.
Answered 11/23/2010 by: honestgoofy
Yellow Belt

Please log in to comment
-2
So I hope you guys are still reading these posts.We do but clearly you don't! :-) Re-read, especially the part about environment variables. Hint: %USERPROFILE%...........
Answered 11/24/2010 by: VBScab
Red Belt

Please log in to comment
0
Thanks Spartacus.

I was able to get this working on both XP and Win7 with a little bit of tweaking. Now I am working on creating a single script for both OS's.
Answered 11/24/2010 by: honestgoofy
Yellow Belt

Please log in to comment
0
ok here th code I am using. This will determins the Server OS and then run a sub routine for each OS. I am trying to publish this via SCCM and it seems to be breaking on both XP and Win7. The code is blue works but the red is not. I am still pretty new at scripting so I need some help either inserting error checking or if anyone know what IO need to do to get it to work.

On a side note if I run this outside of SCCM (on the local machines) it works.
-----------------------------------------------------code----------------------------------------------------------------------------------
Dim strComputer, VerOS, VerBig, Ver9x, Version9x, OS, OSystem
Dim objWMI, objItem, colItems
Dim oWMI, oWSH, oFSO
Dim sAllUsersProfile, oAllUsersFolder, sProfilesRoot, oFolder
Dim colFSOSubFolders, colWMISubFolders, colSubFolders, colSubFolders2
Dim intSize
Dim objFolder, objFolder2, objSubFolder
Dim strFolder, strFolderName
Dim objFile
Dim FolderToDelete
Dim AllUsers
Dim strCommandWin7, strCommandXP

On Error Resume Next ' this is set because the designated file may be locked from deletion

'Determin OS

strComputer = "."
' This is where WMI interrogates the operating system
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem",,48)

' Here we filter Version
For Each objItem in colItems
VerBig = Left(objItem.Version,3)
Next

' Spot VerBig variable in previous section
' Note the output variable is called OSystem

Select Case VerBig
Case "6.1" OSystem = "Windows 7"
Case "6.0" OSystem = "Vista"
Case "5.2" OSystem = "Windows 2003"
Case "5.1" OSystem = "XP"
Case "5.0" OSystem = "W2K"
Case "4.0" OSystem = "NT 4.0**"
Case Else OSystem = "Unknown - probably Win 9x"
End Select
' This will display the complete Operating System version
'Wscript.Echo "Version No : " & VerBig & vbCr & "OS System : " & OSystem


' Instantiate the various objects

strComputer = "."
Set oWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set oWSH = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")

If OSystem = "Windows 7" Then
Call Win7
Else
Call XP
End If


' ***************************************************************************************************************
Sub Win7
'Search and destroy any file with @AIS in the name and send to c:\temp
'WScript.Echo ("Search and destroy any file with @AIS in the name and send to c:\temp")
strCommandWin7 = "cmd /c del c:\users\*@*ais*.txt /s > c:\temp\cookiedeleteWIN7.txt"
' This will display the command that will be run in a command promt
'WScript.Echo (strCommandWin7)
Set StdOut = WScript.StdOut
Set objShellWin7 = CreateObject("WScript.Shell")
set objScriptExecWin7 = objShellWin7.Exec (strCommandWin7)

' Get the Allusers profile folder path first and from this determine profiles parent folder
sAllUsersProfile = oWSH.ExpandEnvironmentStrings("%USERPROFILE%")
Set oAllUsersFolder = oFSO.GetFolder(sAllUsersProfile)
sProfilesRoot = oAllUsersFolder.ParentFolder
FolderToDelete = "\appdata\locallow\sun\java\deployment\cache\6.0"
AllUsers = "\%userprofile%"
' This will display the path of the users profiles
'Wscript.Echo sprofilesroot

' Now enumerate all existing user profile folders

Set oFolder = oFSO.GetFolder(sProfilesRoot)
Set colFSOSubfolders = oFolder.SubFolders

End Sub

' ***************************************************************************************************************
Sub XP

'Search and destroy any file with @AIS in the name and send to c:\temp
'WScript.Echo ("Search and destroy any file with @AIS in the name and send to c:\temp")
strCommandXP = "cmd /c del C:\Docume~1\*@*ais* /s > c:\temp\cookiedirXP.txt"
' This will display the command that will be run in a command promt
'WScript.Echo strCommandXP
Set StdOut = WScript.StdOut
Set objShellXP = CreateObject("WScript.Shell")
set objScriptExecXP = objShellXP.Exec (strCommandXP)

' Get the Allusers profile folder path first and from this determine profiles parent folder
sAllUsersProfile = oWSH.ExpandEnvironmentStrings("%allUSERsPROFILE%")
Set oAllUsersFolder = oFSO.GetFolder(sAllUsersProfile)
sProfilesRoot = oAllUsersFOlder.ParentFolder
FolderToDelete = "\Application Data\Sun\Java\Deployment\cache\6.0"
AllUsers = "\all users"
' This will display the path of the users profiles
'WScript.Echo sprofilesroot

' Now enumerate all existing user profile folders

Set oFolder = oFSO.GetFolder(sProfilesRoot)
Set colFSOSubfolders = oFolder.Subfolders

End Sub

' ***************************************************************************************************************
' Now go through each existing user profile folder looking for the designated folder to delete
For Each objSubfolder in colFSOSubfolders

if oFSO.FolderExists(sProfilesRoot & "\" & objSubfolder.Name & FolderToDelete) then
intSize = 0
strFolderName = sProfilesRoot & "\" & objSubfolder.Name & FolderToDelete
WScript.Echo (strFoldername)
Set colSubfolders = oWMI.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")
ReDim Preserve arrFolders(intSize)
arrFolders(intSize) = strFolderName
intSize = intSize + 1

For Each objFolder in colSubfolders
GetSubFolders strFolderName

Next
For i = Ubound(arrFolders) to 0 Step -1
strFolder = arrFolders(i)
strFolder = Replace(strFolder, "\", "\\")
Set colFolders = oWMI.ExecQuery _
("Select * from Win32_Directory where Name = '" & strFolder & "'")

For Each objFolder in colFolders
errResults = objFolder.Delete
Next
Next
end if
Next


' ***************************************************************************************************************
Sub GetSubFolders(strFolderName)
Set colSubfolders2 = oWMI.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")

For Each objFolder2 in colSubfolders2
strFolderName = objFolder2.Name
ReDim Preserve arrFolders(intSize)
arrFolders(intSize) = strFolderName
intSize = intSize + 1
GetSubFolders strFolderName
Next
End Sub

' ****************************************************************************************************************
Answered 12/02/2010 by: honestgoofy
Yellow Belt

Please log in to comment
0
Look at your code: there is far too much duplication. The use of variables will reduce it considerably. For example, you can set the user profile location at the same place where you set the OSSystem variable.

Also, the use of WMI for file/folder manipulation is somewhat convoluted. Stick with the FileSystemObject object. There's lots of code around for it, particularly for recursing through files/folders. There are some good shells at http://www.computerperformance.co.uk
Answered 12/02/2010 by: VBScab
Red Belt

Please log in to comment
0
Hey mike. the best way to delete the folder in short code. use this script

Go to notepad and type this.
Dim a
Set a = CreateObject("Scripting.FileSystemObject")
a.DeleteFolder("c:\Documents and Settings\Humm")

save the document as xx.vbs. click on the vbs file and see.. The file will be deleted

Regards
Prasath(09944917252)
Answered 12/20/2010 by: prasath
Yellow Belt

Please log in to comment
0
Guys, I have a question. How to create a code to move the file which has information for yesterday from folder to another folder and create another file for today??
Answered 12/26/2010 by: fageeh
Yellow Belt

Please log in to comment
0
One, please don't cross-post. If your question hasn't been answered, then perhaps no-one is able to help you.

Two, there must be a quadzillion code samples on the web for handling file dates. Use a search engine.
Answered 12/27/2010 by: VBScab
Red Belt

Please log in to comment
0
Dear Experts,

I know it's stupid to ask but I have really no idea how to create script to delete my 2.0 folder inside "%username%>Local Settings>Apps . Can someone help to write the script? I need the script to be able to use in both XP and Windows 7 environment. Please help me.
Answered 09/17/2011 by: MarverickMY
Yellow Belt

Please log in to comment
Answer this question or Comment on this question for clarity