2

I am trying to clear IE cache of a remote computer by using the following script in Powershell

$computer= read-host "computer name" psexec \\$computer -i 0 cmd /c RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351

It runs on the remote computer (the user can see it running) but does not clear cache of the logged on user.

I've also tried to copy a batch file containing the command RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351 on to the logged on user's desktop and then running it

$computer= read-host "computer name" $user = read-host "User ID" copy C:\test.bat \\$computer'\C$\Documents and Settings\'$user'\Desktop' PsExec \\$computer -i 0 cmd /c "C:\Documents and Settings\$user\Desktop\test.bat"

Still no joy

If the user runs the batch file himself it clears his cache.

I just basically want to clear the IE cache of the logged on user remotely.

Any help will be highly appreciated.

Cheers

Ronnie

Ronnie S
  • 23
  • 1
  • 3
  • What happens if you use the task scheduler to invoke the batch as the target user? – AlexPawlak May 08 '14 at 12:06
  • Thanks for your reply @Koliat. I've never tried that before but will try to search on the internet. Cheers – Ronnie S May 12 '14 at 02:18
  • Did you try the solution in other question ?http://stackoverflow.com/questions/12621969/clear-cache-of-browser-by-command-line – AlexPawlak May 12 '14 at 06:47
  • Yeah I've tried that too.. no joy! I tried to use the task scheduler but that needs a username and password. – Ronnie S May 13 '14 at 07:42
  • I would assume one thing: Rundll32.exe and the InetCpl are looking for user-context of the process owner. Using PsExec, you are calling the process with your own impersonated session rather than the console host. Can you validate that in practice? Connect to RDP with your own session, browse the internet and then call the process remotely, see if it clears YOUR cache. I am not sure about the "advantage" of using built-in DLL to manually deleting cache and history files (option 8), but still, you could just use Remove-Item or have a batch do "del" to trash the cache? – AlexPawlak May 13 '14 at 14:03

1 Answers1

2

It's incredibly difficult to impersonate a user without knowing their password (imagine the security implications!). In my experience it's easier to run it as either a logon or logoff script using group policy.

Jeremiah
  • 65
  • 1
  • 5
idarryl
  • 749
  • 1
  • 11
  • 21