Link to home
Start Free TrialLog in
Avatar of Duke Kahanamoku
Duke KahanamokuFlag for United States of America

asked on

I need Scripts that will run off of group policy to automatically run disk defrag, delete all temp files for all local users, and run disk check with a reboot.

I am not a programmer of any kind but I do the administration for a computer network of 40 workstations and 2 servers.  The workstations are on XP and Vista.  I need some help (even a little training) on getting these scripts made and implemented that would allow me to use my GP to run these scripts on the first monday of the month.  I need the scripts to automatically run:

Defrag
Disk check with fix
delete temp folders under all local users (local settings/temp)
delete all temp internet files for firefox (IE is already setup in GP)
Avatar of arnold
arnold
Flag of United States of America image

First, Are these users setup as roaming?  This could be the first step. In a roaming profile configuration, local settings are not included and can be excluded from the roaming profile in the GPO.  Similarly the cache directory for Firefox could be excluded from roaming.
The GPO cah be configured to delete the local copy of the profile on logout.

Disk defrag might no be necessary,
but you can add a script to the computer settings\startup script that will have the following line
defrag -f c:

The problem you will run into is that the defrag will run every time the computer starts.
Avatar of Duke Kahanamoku

ASKER

I am not quite sure if they are setup as roaming but each local machine has the username/domain setup within the local machine i.e. if the domain is down the users are able to access their accounts.  (I guess that is roaming correct?)

Good thinking on the defrag.  I could add this manually each month during my maintenance schedule and during reboot have it run.  
A roaming profile means that no mater which system the user logs into, they always have the same settings without the need to configure them anew.

Pick a user and look at their configuration in the AD, do they have anything defined for the Profile Path?  This will answer whether the users are or are not roaming.

If it turns out that your settup is using roaming profiles, it might be that a GPO is not configured to delete the roaming profile on logout.

You can use folder redirection if that is not being used to limit the size of the profile that has to be downloaded upon login from the server.
CUrrently I do not have anything in the AD user profile path for any of my users.  So I do not have the roaming enabled.....
So how about those scripts/batch files?  Do you think you can help me with those?
You do not need any batch files.
Configure your users to use roaming profiles (this will also provide you and your users the "security" that their files will not disappear if the system they work on fails) .  Then set the GPO to delete Profiles from the local system on logout.
For the defrag, in the GPO's computer Configuration\windows settings\scripts (startup\shutdown)\startup.  Go to show file.
Create here a file
with contents of
defrag -f c:

Save the file. Then add the filename.
If you want to have the ability to change which drive will be defragmented without the need to alter the script, use
defrag -f %1%

note that you would have to specify the drive letter (c:, e:) as a parameter in the GPO.
Arnold, thanks for the suggestion regarding roaming profiles.  If I am understanding you correctly the roaming profile of all the users (10) would be stored on the server along with all their data that is stored on their current desktop?  Also how does this work with applications they need to use?  Does the application need to be installed on the workstation (such as MS Office) or does the roaming profile store that data as well?  Are all applications compatable with this type of configuration?  

Most of the businesses I work with only have 5-10 computers and so I have never looked at roaming profiles before. I'll do more research on this but please answer these questions above to help me quickly solve my current problem.

Thank you.
The applications need to be installed on the systems. The only thing that is stored in the roaming profile is the same data normally stored in the c:\documents and settings\username (My documents, Desktop, etc.).
With roaming setup, a user can use any computer and have access to the same data.  In the GPO, you can exclude the copying of the temp directory.

The applications do not know nor do they care whether the user profile is of local type or roaming since the type of profile is transparent to the application.

When the user logs in, the data \\server\profileshare\username is copied to the workstation as c:\documents and settings\username.  As long as c:\documents and settings\username is where the application is looking for the file, that is where the files are found. When the user logs out, the workstation copies the data back to the server and if the option is set, deletes the local copy if the copy was successful.

You could use the \\workstationname\c$ to access each workstation's C drive and then go through the documents and settings to delete unneeded profile files. note that using this method data could be lost if a user who used this system returns since it seems each workstation could have different files for the same user.
This sounds like a good strategy for some of the businesses I work with but before I do some more research on this I am hoping that you might still be willing to help me with using scripts at this time.  
try the \\workstation\c$ method, how many user profiles exist on the system? I suspect that the way it is currently setup, the same user uses the same system day in and day out.  

Here is a reference to wscript resources that handles fileobject access.

http://www.microsoft.com/technet/scriptcenter/guide/sas_scr_qdsc.mspx?mfr=true

 
ASKER CERTIFIED SOLUTION
Avatar of arnold
arnold
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok to summarize here and see if I have all my questions answered:

To delete my local system user temp folders I can run this script:
del /F /Q "%userprofile%\local settings\Temp\*"

To delete Internet Explorer Temp Internet Files I can set that up in the GP

Can you give me the script to reboot and then run scandisk upon reboot?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
FYI To avoid having the start up process take too long use the following in the script:
start "" /MIN c:\windows\system32\defrag.exe %1%
To replace the
c:\windows\system32\defrag.exe -f %1%.