[ITEM]

Apr 19, 2018 - Hello all, I have been trying to set up a VB script to delete all files older than 2 days in a specific folder and all subfolders without deleting the. Apr 05, 2005  In fact, using WMI the only way to delete a folder in SP2 is to first delete all its subfolders. And, of course, before you can delete a subfolder you have to delete all of its subfolders. Warcraft 2 battle net edition download torrent. And before you can delete any of those – well, it just goes on and on from there.

Trust us: we’re well aware that this was way easier in Windows 2000. But at least now we’re ready to start deleting folders. If you look at the items in our array, they happen to be exactly opposite of what we need; for example, the Archive folder is the first item in our array, but it has to be the last item that we delete.

If we could invert the array – making the first last and the last first, to steal a phrase – we’d be in business. That’s where this block of code comes in: For i = Ubound(arrFolders) to 0 Step -1 strFolder = arrFolders(i) strFolder = Replace(strFolder, “ ”, “ ”) Set colFolders = objWMIService.ExecQuery _ (“Select * from Win32_Directory where Name = ‘” & strFolder & “‘”) For Each objFolder in colFolders errResults = objFolder.Delete Next Next What we’re doing here is reading our array from the bottom up. We’re creating a loop that starts with the very last item in the array; that’s what the Ubound (upper bound) function is for. We’re then going to work our way down to the first item in the array: item 0. (As you might recall, the first element in an array is always item 0, not item 1.) The Step -1 function just means that we step backwards rather than forward: instead of going 0-1-2-3, we’re going 3-2-1-0. This is how we can start deleting at the bottom of the tree. Of course, before we can do that we need to adjust the folder paths; that’s what we do here: strFolder = Replace(strFolder, “ ”, “ ”) Our folder paths are going to look like this: C: Scripts Archive Subfolder A1 Subfolder B1.

That’s fine, except that we need to include these paths in a WQL query. Consequently, we need to double up all the ’s, resulting in paths that look like this: C: Scripts Archive Subfolder A1 Subfolder B1.

We use the Replace function to replace each with. Alma tv ustj kamenogorsk programma peredach. You’re right: there’s nothing straightforward about this script, is there? With our new folder paths we can then use WMI to connect to the folder in question and – at long last – use the Delete method to actually delete the folder. That’s what happens here: Set colFolders = objWMIService.ExecQuery _ (“Select * from Win32_Directory where Name = ‘” & strFolder & “‘”) For Each objFolder in colFolders errResults = objFolder.Delete Next Having disposed of Subfolder B1, we can then start working our way up the tree, eventually deleting C: Scripts Archive. Five million lines of code later, we’re done, and C: Scripts Archive has been deleted. We’re not saying it’s a particularly elegant solution, but it is a solution, and it will work on all versions of Windows.

And because it uses WMI, it works equally well on remote machines as it does on the local computer. So there you have it: deleting a folder and all its subfolders, a subject we’ve vowed never to deal with again.

Well, at least not until the next service pack comes out.

[/ITEM]
[/MAIN]

Apr 19, 2018 - Hello all, I have been trying to set up a VB script to delete all files older than 2 days in a specific folder and all subfolders without deleting the. Apr 05, 2005  In fact, using WMI the only way to delete a folder in SP2 is to first delete all its subfolders. And, of course, before you can delete a subfolder you have to delete all of its subfolders. Warcraft 2 battle net edition download torrent. And before you can delete any of those – well, it just goes on and on from there.

Trust us: we’re well aware that this was way easier in Windows 2000. But at least now we’re ready to start deleting folders. If you look at the items in our array, they happen to be exactly opposite of what we need; for example, the Archive folder is the first item in our array, but it has to be the last item that we delete.

If we could invert the array – making the first last and the last first, to steal a phrase – we’d be in business. That’s where this block of code comes in: For i = Ubound(arrFolders) to 0 Step -1 strFolder = arrFolders(i) strFolder = Replace(strFolder, “ ”, “ ”) Set colFolders = objWMIService.ExecQuery _ (“Select * from Win32_Directory where Name = ‘” & strFolder & “‘”) For Each objFolder in colFolders errResults = objFolder.Delete Next Next What we’re doing here is reading our array from the bottom up. We’re creating a loop that starts with the very last item in the array; that’s what the Ubound (upper bound) function is for. We’re then going to work our way down to the first item in the array: item 0. (As you might recall, the first element in an array is always item 0, not item 1.) The Step -1 function just means that we step backwards rather than forward: instead of going 0-1-2-3, we’re going 3-2-1-0. This is how we can start deleting at the bottom of the tree. Of course, before we can do that we need to adjust the folder paths; that’s what we do here: strFolder = Replace(strFolder, “ ”, “ ”) Our folder paths are going to look like this: C: Scripts Archive Subfolder A1 Subfolder B1.

That’s fine, except that we need to include these paths in a WQL query. Consequently, we need to double up all the ’s, resulting in paths that look like this: C: Scripts Archive Subfolder A1 Subfolder B1.

We use the Replace function to replace each with. Alma tv ustj kamenogorsk programma peredach. You’re right: there’s nothing straightforward about this script, is there? With our new folder paths we can then use WMI to connect to the folder in question and – at long last – use the Delete method to actually delete the folder. That’s what happens here: Set colFolders = objWMIService.ExecQuery _ (“Select * from Win32_Directory where Name = ‘” & strFolder & “‘”) For Each objFolder in colFolders errResults = objFolder.Delete Next Having disposed of Subfolder B1, we can then start working our way up the tree, eventually deleting C: Scripts Archive. Five million lines of code later, we’re done, and C: Scripts Archive has been deleted. We’re not saying it’s a particularly elegant solution, but it is a solution, and it will work on all versions of Windows.

And because it uses WMI, it works equally well on remote machines as it does on the local computer. So there you have it: deleting a folder and all its subfolders, a subject we’ve vowed never to deal with again.

Well, at least not until the next service pack comes out.