Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27184

Delete a file with a given extension

$
0
0
Hi All,

Wondering if anyone can help, I'm attempting to delete a .ost file from a users roaming profile, I'm using the following code:

Dim strComputer, oWSH, oWMI, oFSO, AppDataFolder

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

For Each file As String In IO.Directory.GetFiles(AppDataFolder & "\Thinstall\Microsoft Standard 2010 KMS\%Local AppData%\Microsoft\Outlook","*.ost")
IO.File.Delete(file)
Next


I keep getting "Expected In" error message on line 9 char 15. Any idea why? Sorry but I literally do no VB coding so am a bit lost.

Regards,
Ross

Viewing all articles
Browse latest Browse all 27184

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>