Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Group policy and running a .bat file

Posted on 2006-11-02
4
Medium Priority
?
396 Views
Last Modified: 2013-12-04
Hello experts...

I have a question with regard to .bat files and group policies.  Have a log off .bat file that runs defrag and disk cleanup when users log off each night.  The .bat file is located on the file server.  Since removing the user from the local admin group to power users group, I've noticed the .bat file not running when users log off at night.  

So the question is, how do I get the batch file to execute on the local machine using group policies when the user is power user and not an local admin user?

Windows 2000 DC and XP Pro workstations.

Thanks.
0
Comment
Question by:braman1
[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
  • 3
4 Comments
 
LVL 38

Expert Comment

by:Shift-3
ID: 17860281
The file should execute, but only administrators have the right to defragment disks.  Since the job is running in the user's context, it doesn't have the rights necessary.

It would be better to use scheduled tasks to run your disk cleanup and defrag jobs.  That way they won't slow down logoffs and they will run even if nobody logs in.  Here are some instructions:
http://www.edbott.com/weblog/?p=1268
http://www.microsoft.com/windowsxp/using/setup/expert/crawford_october08.mspx

You can mass-deploy these scheduled tasks to all of your workstations using the AT command.
0
 

Author Comment

by:braman1
ID: 17866751
Could you expand on the AT command?  I really wanted to avoid having to visit each workstation and setting up the scheduled task.  I was hoping to roll out using GP.  

Thanks.

0
 
LVL 38

Accepted Solution

by:
Shift-3 earned 2000 total points
ID: 17868031
You can view the parameters of the AT command by typing "at /?" at the command line.  As an example, running the following command creates a scheduled task on the target computer which defrags the C: drive at 2:00 am every Saturday.
at "\\targetcomputer" 02:00 /every:saturday defrag c:

Setting up Disk Cleanup to run unattended is a little trickier, as you first have to customize it using the /sageset switch.  See these instructions:
http://www.edbott.com/weblog/?p=1274

Running "cleanmgr /sageset:5555" and selecting Temporary Files creates a REG_DWORD named StateFlags5555 with a value of 2 under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files.  It creates a similar entry for any other option you select.

You can use a script to pull this all together.  First create a text file named computerlist.txt.  Enter the names of all the workstations into it, one per line.  Then create a file named schedule.cmd in the same directory and paste the text between the lines into it.

__________
@echo off
setlocal

set RegPath=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches

for /F "tokens=*" %%G in (computerlist.txt) do (

 REM Sets Disk Cleanup registry entries.  Add additional lines here to include other cleanup options.
 reg add "\\%%G\%regpath%\Internet Cache Files" /v StateFlags5555 /t REG_DWORD /d 2 /f
 reg add "\\%%G\%regpath%\Old ChkDsk Files" /v StateFlags5555 /t REG_DWORD /d 2 /f
 reg add "\\%%G\%regpath%\Temporary Files" /v StateFlags5555 /t REG_DWORD /d 2 /f

 REM Schedules Disk Cleanup
 at "\\%%G" 01:00 /every:saturday cleanmgr /sagerun:5555

 REM Schedules Defrag
 at "\\%%G" 02:00 /every:saturday defrag c:

)

endlocal
__________

Running this creates a scheduled task on each computer which runs Disk Cleanup at 1:00 am and defrags the C: drive at 2:00 am every Saturday.
0
 
LVL 38

Expert Comment

by:Shift-3
ID: 17868060
Oops, those reg add commands aren't right.  You might have to deploy those using a startup script instead.
0

Featured Post

2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

Question has a verified solution.

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

The term "Bad USB" is a buzz word that is usually used when talking about attacks on computer systems that involve USB devices. In this article, I will show what possibilities modern windows systems (win8.x and win10) offer to fight these attacks wi…
Article by: btan
The intent is not to repeat what many has know about Ransomware but more to join its dots of what is it, who are the victims, why it exists, when and how we respond on infection. Lastly, sum up in a glance to share such information with more to help…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

650 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