Solved

Ccleaner is not working using shutdown script in GPO

Posted on 2014-09-11
4
408 Views
Last Modified: 2014-09-11
I created a script to run CCleaner during the shutdown/restart process of the PCs. The script works fine when I launch it manually in a PC (The computer is member of the OU in AD where the GPO is linked to) under a user’s profile, but does not show any sign of running Ccleaner during the shutdown/restart process(I still see the recycle bin full).
In order to troubleshoot the issue I added some lines in the script that will create a file (shutdown.log) and add comments to it. See the script bellow:
@ECHO OFF
:: Find Windows version x86 or x64

echo %date% %time%: Shutdown script starting> c:\shutdown.log
if exist "%ProgramFiles(x86)%" GOTO 64bit
pushd \\server-intdb\GeneralRepository\PortableCCleaner4_10\>> c:\shutdown.log 2>&1
CCleaner.exe /AUTO>> c:\shutdown.log 2>&1
popd
echo %date% %time%: Shutdown script 32bit ended>> c:\shutdown.log
GOTO END
:64bit
pushd \\server-intdb\GeneralRepository\PortableCCleaner4_10\>> c:\shutdown.log 2>&1
CCleaner64.exe /AUTO>> c:\shutdown.log 2>&1
popd
echo %date% %time%: Shutdown script 64bit ended>> c:\shutdown.log
:END

Open in new window

After the reboot process I can see that the shutdown.log file was created and two lines were added to it:
10/09/2014 16:36:40.01: Shutdown script starting
10/09/2014 16:36:45.45: Shutdown script 32bit ended

Which means that the shutdown script is running, but I cannot see any indication that Ccleaner was ran.
Now, is my understanding that shutdown scripts are running as the user LOCAL SYSTEM, which by default doesn't have access to user profiles. Question:
1-      Any suggestion how can I run the script and perform the cleanup in the user’s profile?
0
Comment
Question by:Hotspex
  • 2
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
Gabriel Clifton earned 500 total points
ID: 40317270
You could make this a logoff script which would be users profile. CCleaner also has a pro version which has all users cleanup.
0
 

Author Comment

by:Hotspex
ID: 40317306
The restart process is caused by a third party app. (external). Will the logoff script work in that case too? I'll test it and get back to you
0
 

Author Comment

by:Hotspex
ID: 40317693
Thanks. It works as LOGOFF script.
0
 
LVL 13

Expert Comment

by:Gabriel Clifton
ID: 40317818
No problem, glad to help.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
All of the resources available today make learning a new digital media easier than ever-- if you know where to begin. This is a clear, simple guide to a few of the basic digital art mediums and how to begin learning them on your own.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question