Solved

Ccleaner is not working using shutdown script in GPO

Posted on 2014-09-11
4
426 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How to record audio from input sources to your PC – connected devices, connected preamp to record vinyl discs, streaming media, that play through your audio card: Vista, Windows 7, Windows 8, Windows 8.1 and Windows 10 – both 32 bit & 64.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 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