So far as the batch file is concerned, I wrote this one which will accomplish the task and it's safe.
Code:
@echo off
setlocal enabledelayedexpansion
for /f "tokens=5 delims=\" %%f in ('reg query hkcu\software\microsoft\office^|findstr "[0-9][0-9][.][0-9]"') do (
call :ver %%f
)
goto :eof
:ver
for /f "skip=2 tokens=2 delims=:" %%f in ('reg query hkcu\software\microsoft\office\%1\outlook\security /v outlooksecuretempfolder') do (
set var=%systemdrive%%%f
if exist "!var!" (
echo Found: %1
echo Folder: !var!
echo Cleaning...
rd "!var!" /s /q
echo Done!
) else (
echo Folder !var! found in registry does not exist, skipping.
)
)
Next, you need to invoke the group policy editor. To do that :
1. Click the Start button
2. Select "Run"
3. type "gpedit.msc" (without the quotes) in the "open" box and click OK or press Enter
4. Windows opens up the Group Policy editor.
In the left part of the screen, navigate to Computer Configuration->Windows Settings and select "Scripts (Startup/shutdown)".
In the right part of the screen, right-click "Shutdown" and select "properties"
In the shutdown properties dialog, click the "add button"
Enter the path and batch file name in the script name field (leave the script parameters field empty for this example)
Click ok
Click ok once more
You can now close the Group Policy editor, your Windows shutdown script is ready and will be executed each time you shut down Windows.
If you are curious where you can add logon/logoff scripts, they are in the Group Policy editor under User Configuration->Windows Settings->Scripts (Logon/logoff)
This was posted for prosperity... ;-)
Originally Posted by
Barkley Bees
Trying to find the best way to have XP client PC's clear their Outlook 2003
temporary folder data on system shutdown (C:\Documents and
Settings\%userprofile%\Local Settings\Temporary Internet Files\OLK*). Can
this be accomplished using Group Policy to set the "shutdown script" and use
something like the below in a .bat file:
--------------------------------------------------------------------------------
cd %userprofile%\Local Settings\Temporary Internet Files\OLK*
del *.* /s /f /q
--------------------------------------------------------------------------------
Can a .bat file be assigned as a 'shutdown script' via group policy?
Appreciate any feedback or optional advice. Thank you.
Bookmarks