Hello,
I am working on a VB script to delete files from the OLK directories on my Citrix server. I am new with VBS and I need to know how to use the below command line in a VB script.

c:\del "C:\Documents and Settings\%Username%\Local Settings\Temporary Internet Files\OLK*"

Can someone help me out?

Dani AI

Generated

The simplest, reliable approach is to build the per-user path inside VBScript (do not hard-code a machine-wide path) and delete matching files with the Scripting.FileSystemObject. That avoids quoting problems when calling cmd.exe and gives control over attributes and error handling. asked how to translate the command into VBS; pointed to useful samples — the pattern below shows how to expand the current user profile, enumerate the target folder, and remove files whose names start with the OLK prefix.

Set shell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

profile = shell.ExpandEnvironmentStrings("%USERPROFILE%")
target = profile & "\Local Settings\Temporary Internet Files"

If fso.FolderExists(target) Then
  Set fld = fso.GetFolder(target)
  For Each fil In fld.Files
    If LCase(Left(fil.Name,3)) = "olk" Then
      On Error Resume Next
      fso.DeleteFile fil.Path, True
      On Error GoTo 0
    End If
  Next
End If

Notes and cautions: run the script in each user context (logon script or scheduled task) — running as SYSTEM will act on the wrong profile. On newer Windows versions the cache location differs (Users instead of Documents and Settings), so adjust the base path or use environment variables. Test on a non-production account first, handle locked files (they cannot be deleted), and log errors so you can confirm what was removed before wide deployment.

Recommended Answers

All 2 Replies

check this url. i dont know whether it may help u or not.

Regards
Shaik Akthar

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.