Script to delete a folder gained from registry info
Hi I am new to scripting and I am trying to create a script that will identify a folder from the registry but then delete it from within windows then create the same folder.
The folder is the Outlook Secure Temp Folder, the reason is due to only a couple of staff seem to have an issue with this folder always filling up and then not being able to see images in outlook when received. I beleive this is being created through the way the users open images/documents within outlook, alter the file in some way then forwarding or replying.
Anyway so far what I have is I can obtain the information from the registry for the location of the folder but I just cant seem to get the next step of delelting this location in windows. This is what I have so far;
Option Explicit
Dim objShell
Dim regSecureTempFolder
Dim SecureTempFolder
regSecureTempFolder = "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0" & _ "\Outlook\Security\OutlookSecureTempFolder"
Set objshell = CreateObject("Wscript.Shell")
SecureTempFolder = objshell.RegRead(regSecureTempFolder)
Could someone please show me the way.
Greatly appreciate your assistance.
Cheers
PaulDG
The folder is the Outlook Secure Temp Folder, the reason is due to only a couple of staff seem to have an issue with this folder always filling up and then not being able to see images in outlook when received. I beleive this is being created through the way the users open images/documents within outlook, alter the file in some way then forwarding or replying.
Anyway so far what I have is I can obtain the information from the registry for the location of the folder but I just cant seem to get the next step of delelting this location in windows. This is what I have so far;
Option Explicit
Dim objShell
Dim regSecureTempFolder
Dim SecureTempFolder
regSecureTempFolder = "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0" & _ "\Outlook\Security\OutlookSecureTempFolder"
Set objshell = CreateObject("Wscript.Shell")
SecureTempFolder = objshell.RegRead(regSecureTempFolder)
Could someone please show me the way.
Greatly appreciate your assistance.
Cheers
PaulDG
0 Comments
[ + ] Show comments
Answers (3)
Please log in to answer
Posted by:
anonymous_9363
15 years ago
Without doubt, someone will ride up on a white charger and rescue you but have a search first. I can find thousands of examples for folder deletion.
[puts on drum to bang...]
Since you're new to scriptiong, I'll take this opportunity to say that I cannot emphasise enough the importance of defensive programming. Taking your script as an example, you have:
- a hard-coded value for the MS Office version. If you move to Office 2007, your script will stop working.
- ZERO error-trapping. In script (and in all forms of programming) assume NOTHING. For example, your script should check that the shell object got created - If IsObject(objShell) Then - before it tries to use it. Check that each part of the registry key you're trying to read exists and so on.
As an aside, you'll very quickly find RegRead and RegWrite to be limited in scope. Grab cRegistry.VBS (from http://www.jsware.net, if memory serves) and use that. It will serve as a nice introduction to some good techniques, as well as to using VBS files as class files in general.
[puts on drum to bang...]
Since you're new to scriptiong, I'll take this opportunity to say that I cannot emphasise enough the importance of defensive programming. Taking your script as an example, you have:
- a hard-coded value for the MS Office version. If you move to Office 2007, your script will stop working.
- ZERO error-trapping. In script (and in all forms of programming) assume NOTHING. For example, your script should check that the shell object got created - If IsObject(objShell) Then - before it tries to use it. Check that each part of the registry key you're trying to read exists and so on.
As an aside, you'll very quickly find RegRead and RegWrite to be limited in scope. Grab cRegistry.VBS (from http://www.jsware.net, if memory serves) and use that. It will serve as a nice introduction to some good techniques, as well as to using VBS files as class files in general.
Posted by:
Pauldg
15 years ago
Thanks for the information VBScab, I will definately look at cRegistry.VBS.
One of the ideas of ceating this script is to incorporate it to a current network user startup script, I am just trying to create the base of it first, but the more info I have the better I know it will help in the future with creating scripts.
I am open to all suggestions & comments.
Thanks once again
One of the ideas of ceating this script is to incorporate it to a current network user startup script, I am just trying to create the base of it first, but the more info I have the better I know it will help in the future with creating scripts.
I am open to all suggestions & comments.
Thanks once again
Posted by:
sk
15 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.