• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 479
  • Last Modified:

vbscript for deleting outlook files

I need to know how to vbscript and make a batch file of  the below. I want it to seek out if machine is xp or vista and if it is then I want it to close the outlook and delete the files and then open back up outlook. This applies to just outlook 2007. It would be nice if it worked on outlook 2003 but outlook 2007 is main concern

Outcmd.dat:
C:\Documents and Settings\<username>\Local Settings\Application Data\Microsoft\Outlook
C:\Users\<username>\AppData\Roaming\Microsoft\Outlook

Extend.dat:
C:\Documents and Settings\<username>\Application Data\Microsoft\Outlook
C:\Users\<username>\AppData\Local\Microsoft\Outlook

Frmcache.dat:
C:\Documents and Settings\<username>\Application Data\Microsoft\Outlook
C:\Users\<username>\AppData\Local\Microsoft\FORMS

Views.dat:
C:\Documents and Settings\<username>\Application Data\Microsoft\Outlook
C:\Users\<username>\AppData\Local\Microsoft\Outlook
0
heydorft
Asked:
heydorft
  • 5
  • 5
1 Solution
 
heydorftAuthor Commented:
sorry let me clairfy. By seeking out I mean on the individual machine I run it on. Not over a domain or active directory situation
0
 
David LeeCommented:
Hi, heydorft.

Try this.  This solution uses code from raisor's accepted solution from this question: http://www.experts-exchange.com/Programming/Misc/Q_21765271.html
dim objShell, objFSO, strOS, strVerKey, strVersion
Set objShell = CreateObject("WScript.Shell")
strOS = objShell.ExpandEnvironmentStrings("%OS%")
strUser = objShell.ExpandEnvironmentStrings("%USERNAME%")
If strOS = "Windows_NT" Then
   strVerKey = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
   strVersion = objShell.regread(strVerKey & "ProductName") & " " & objShell.regread(strVerKey & "CurrentVersion") & "." & objShell.regread(strVerkey & "CurrentBuildNumber")
Else
  strVerKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\"
  strVersion = objShell.regread(strVerKey & "ProductName") & " " & objShell.regread(strVerKey & "VersionNumber")
End if
Set objFSO = CreateObject("Scripting.FileSystemObject")
If InStr(1, strVersion, "Windows Vista") Then
    objFSO.DeleteFile("C:\Users\" & strUser & "\AppData\Roaming\Microsoft\Outlook\Outcmd.dat")
    objFSO.DeleteFile("C:\Users\" & strUser & "\AppData\Local\Microsoft\Outlook\Extend.dat")
    objFSO.DeleteFile("C:\Users\" & strUser & "\AppData\Local\Microsoft\FORMS\Frmcache.dat")
    objFSO.DeleteFile("C:\Users\" & strUser & "\AppData\Local\Microsoft\Outlook\Views.dat")
Else
    If InStr(1, strVersion, "Windows XP") Then
        objFSO.DeleteFile("C:\Documents and Settings\" & strUser & "\Local Settings\Application Data\Microsoft\Outlook\Outcmd.dat")
        objFSO.DeleteFile("C:\Documents and Settings\" & strUser & "\Application Data\Microsoft\Outlook\Extend.dat")
        objFSO.DeleteFile("C:\Documents and Settings\" & strUser & "\Application Data\Microsoft\Outlook\Frmcache.dat")
        objFSO.DeleteFile("C:\Documents and Settings\" & strUser & "\Application Data\Microsoft\Outlook\Views.dat")
    End If
End If
Set objShell=nothing
Set objFSO = Nothing

Open in new window

0
 
heydorftAuthor Commented:
I get this below

script: c:\users\they\desktop\outlook.vbs
line: 1
char: 1
error: expected statement
code: 800a0400
source: microsft vbscript compilation error
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
David LeeCommented:
Unless there was a problem copying and pasting, then I don't see how there can be an error on line #1.  Did the line numbers get copied too?  If they were, then that's the problem.  There shouldn't be any line numbers.
0
 
heydorftAuthor Commented:
line:1 was my fault not the true error

I get the below
I get this below

script: c:\users\they\desktop\outlook.vbs
line: 14
char: 5
error: file not found
code: 800A0035
source: Microsoft VBScript runtime error
0
 
David LeeCommented:
I didn't verify the paths.  I used exactly what you posted.  Verify that strUser contains the correct user name.  If it does, then verify the path and file name.
0
 
heydorftAuthor Commented:
how do I verify struser
0
 
David LeeCommented:
Insert this command after line #4

    WScript.Echo strUser

This will cause a dialog-box to popup showing the value of strUser.
0
 
heydorftAuthor Commented:
I will look at this tonight..been very swamped...thanks
0
 
David LeeCommented:
No problem.  I'll be here when you do get to it.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now