[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 437
  • Last Modified:

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)
0
Duncan007
Asked:
Duncan007
  • 8
  • 6
2 Solutions
 
arnoldCommented:
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.
0
 
Duncan007Author Commented:
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.  
0
 
arnoldCommented:
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.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Duncan007Author Commented:
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.....
0
 
Duncan007Author Commented:
So how about those scripts/batch files?  Do you think you can help me with those?
0
 
arnoldCommented:
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.
0
 
Duncan007Author Commented:
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.
0
 
arnoldCommented:
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.
0
 
Duncan007Author Commented:
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.  
0
 
arnoldCommented:
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

 
0
 
arnoldCommented:
oh a simple login script that does
del /F /Q "%userprofile%\local settings\Temp\*"

This can be setup the same way the startup script was, but you have to go through the user configuration hierarchy.
Should do the trick.%userprofile% is a variable set upon login to reflect the user's profile location.
0
 
Duncan007Author Commented:
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?
0
 
arnoldCommented:
You can set both in GP for the user.

When you add the script into the GPO's computer Configuration\windows settings\scripts (startup\shutdown, make sure to provide the drive letter (c:) as the parameter

Setup the GPO first.  To reboot a system remotely use shutdown -r -f -m \\computername -t seonds -c "Reason for reboot".


Filename defrag.bat
@echo off
c:\windows\system32\defrag.exe -f %1%

Open in new window

0
 
arnoldCommented:
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%.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now