Avatar of howien
howien asked on

Batch to delete IE History folders - files in other user profile

I have classrooms computers require maintenance and manages,
when logged into (as) admin profile, need to run a batch file (below) to delete/remove history FROM other user profile,

Question., what's the correct input to execute that?

(%USER_PROFILE%\%TEMP%\) ?!

-----------

@echo off

REM Clears Temporary Internet Files
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8

REM Clears Cookies
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

REM Clears History
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1

REM Clears Form Data
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16

REM Clears Passwords
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32

REM Clears Delete All
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255

REM Delete All - "Also delete files and settings stored by add-ons"
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351

echo y | chkdsk /f /r
echo y | gpupdate /force
echo enter 'shutdown -a' to abort the shutdown
start "" shutdown -f -r -t 30
exit
Windows BatchMicrosoft DOSShell Scripting

Avatar of undefined
Last Comment
MAdS

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
MAdS

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
ReneGe

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
howien

Hi,
ReneGe:
thanks for the instruction / note - question here.. is this one replaced my whole entire entries before the shutdown command?
I am not good at this at all - please excuse the stupidity question and thank you for your input!
ReneGe

It does not replace your following command lines (btw, I did not look at them, assuming that you tested them):

echo y | chkdsk /f /r
echo y | gpupdate /force
echo enter 'shutdown -a' to abort the shutdown
start "" shutdown -f -r -t 30
exit

Cheers,
Rene
ASKER
howien

hi, ReneGe & MAds:
both doesn't run in dos or windows batch file... wonder if there's something missing in the batch files provided?

thanks!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ReneGe

We are both in batch file land. Would you mind sharing your thoughts and challanges in more in details?

Cheers,
Rene
ASKER
howien

I did a test from the above comments of each EE, you.
With changed on the user profile name in my one of user profile "trainee" as I don't need to delete the admi. Profile but have to run the scheduled task in the same profile to delete "trainee"'s Temp & Temporary Folders...

I again in an rookie land of "Batch" & can't or unable to shares my thoughts - Don't have - right on comment., (off track)

please excuse the lack of background & try lower your standard to tech like one (me)

I do need some guidance & a straight forward method on what I need to do to make it work!

Everything else works in other portion beside the delete IE history folders....  ( chkdsk, gpupdate & shutdown)

Thanks for any expert comment offer!
ReneGe

I don't understand what does not work. Could you please clarify?

Cheers,
Rene
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
MAdS

Try changes below.
If it doesnt work remove first line, copy/paste the results here and inform te What is Windows version in the workstations?

@ECHO OFF

SETLOCAL enabledelayedexpansion
VER
REM FOR XP WORKSTATIONS
VER | FIND /i "version 5" && for /f "delims=?" %%a in ('dir /b "C:\Documents and Settings" ^| find /v /i "All Users" ^| find /v /i "Default User" ^| find /v /i "LocalService"') do (
        TITLE Deleting I.E. temp for [%%a]
        SET Folder=C:\Documents and Settings\%%a\Local Settings\Temporary Internet Files
        rd /s /q "!Folder!"
        IF NOT EXIST "!Folder!" MD "!Folder!"
)

REM FOR W7 WORKSTATIONS
        VER | FIND /i "version 6" && for /f "delims=?" %%a in ('dir /b "C:\Users" ^| find /v /i "public"') do (
        TITLE Deleting I.E. temp for [%%a]
        SET Folder=c:\users\%%a\appdata\local\microsoft\windows\temporary internet files
        rd /s /q "!Folder!"
        IF NOT EXIST "!Folder!" MD "!Folder!"
)

Open in new window

MAdS

And about....
"With changed on the user profile name in my one of user profile "trainee" as I don't need to delete the admi. Profile but have to run the scheduled task in the same profile to delete "trainee"'s Temp & Temporary Folders..."
What???
Just logon with a user that has admin privileges and run the script.