Location: Mail List

Ads

Skyscraper

The GPTalk Mailing List

The GPTALK mailing list is where you can send and receive email related to Windows Group Policy. You must subscribe to the list to send and receive mail from the list. The purpose of the list is to provide a forum for asking and answering technical questions related to Group Policy. Any question is fair game as long as it is related to Windows Group Policy.  The Archives for this list can be found on this page.

 

List Posts

Subject: [gptalk] Sched Task via GP?
Prev Next
You are not authorized to post a reply.

AuthorMessages
shanewillifordUser is Offline

Posts:46

12/17/2009 2:20 PM  
Hi all..
I was wondering if you guys had a script or something to run a disk defrag sched task via GP. I don't have GPP implemented yet, so I can't do it the traditional GP way...I'll need a startup/logon script. :(

Thanks!

Shane M. Williford
Systems Administrator
VCP, MCSE, MCSA Sec, Sec+, Net+, A+
Mazuma Credit Union
9300 Troost
Kansas City, MO 64131
xxxxxxxxxxxxxxxx<mailto:xxxxxxxxxxxxxxxx>
816-361-4194 x6012


________________________________
Notice: The information transmitted in this e-mail may contain confidential and/ or legally privileged information intended only for the use of the individual(s) named above. Review, use, disclosure, distribution, or forwarding of this information by persons or entities other than the intended recipient(s) is prohibited by law and may subject them to criminal or civil liabilities. Statements and opinion expressed in this e-mail may not represent those of Mazuma Credit Union. All e-mail communications through Mazuma's corporate email system are subject to archiving and review by someone other than the recipient. If you have received this communication in error, please notify the sender immediately and delete/destroy any and all copies of the original message from any computer or network system.

DaemonRootUser is Offline

Posts:29

12/17/2009 2:28 PM  
The following line will make a Scheduled Task called defragTest, which will
run if the system is on idle for more than 60 minutes defragmenting the C:
drive.

Hope this helps.



schtasks /create /SC ONIDLE /I 60 /TN defragTest /TR "defrag C:"



~D~



From: xxxxxxxxxxxxxxxx [mailto:xxxxxxxxxxxxxxxx]
On Behalf Of Shane Williford
Sent: Thursday, December 17, 2009 8:19 AM
To: xxxxxxxxxxxxxxxx
Subject: [gptalk] Sched Task via GP?



Hi all..

I was wondering if you guys had a script or something to run a disk defrag
sched task via GP. I don't have GPP implemented yet, so I can't do it the
traditional GP way.I'll need a startup/logon script. L



Thanks!



Shane M. Williford

Systems Administrator

VCP, MCSE, MCSA Sec, Sec+, Net+, A+

Mazuma Credit Union

9300 Troost

Kansas City, MO 64131

xxxxxxxxxxxxxxxx

816-361-4194 x6012





_____

Notice: The information transmitted in this e-mail may contain confidential
and/ or legally privileged information intended only for the use of the
individual(s) named above. Review, use, disclosure, distribution, or
forwarding of this information by persons or entities other than the
intended recipient(s) is prohibited by law and may subject them to criminal
or civil liabilities. Statements and opinion expressed in this e-mail may
not represent those of Mazuma Credit Union. All e-mail communications
through Mazuma's corporate email system are subject to archiving and review
by someone other than the recipient. If you have received this communication
in error, please notify the sender immediately and delete/destroy any and
all copies of the original message from any computer or network system.


jsclmedaveUser is Offline

Posts:67

12/17/2009 2:28 PM  
Passing this on in hopes it may help you. There was an article in WinIT pro
a couple of years ago. I will work on this today and post the screen shots
on my blog.




Defragmentation is a great way to keep workstations and servers running
at their best performance. Windows Server 2003 comes with a
defragmenter: dfrgntfs.exe. However, you can't automate this
defragmenter unless you purchase a program such as Diskeeper. I didn't
have money for such a program in my budget, so I created and scheduled a
batch file named Defrag.bat.
As Listing 1 shows,

Listing 1: Defrag.bat
@Echo Off
defrag.exe c: -f
defrag.exe e: -f
defrag.exe f: -f

Defrag.bat is a simple program. It uses the defragmenter's command-line
interface (defrag.exe) to run the defragmenter against each drive.
However, I wasn't happy with Defrag.bat for two reasons. First, I had to
let the batch file run while being left logged on with my administrator
ID. Although I locked the screen for security reasons, I didn't want to
leave myself logged on all the time. Second, I wanted more automation.
So, I did some digging around and found a means to automate the
procedure. I found that I could use the Windows scheduler but in a
different way that I didn't know was possible: I could use the AT
command with a batch file.

I created a new batch file, Defrg. bat, which Listing 2 shows.

Listing 2: Defrg.bat
@Echo Off
' BEGIN CALLOUT A
Set logfile=f:\defrag.log
' END CALLOUT A
Echo Started %date%,%time% >>%logfile%
Echo ----------------------------------- >>%logfile% Echo Defragmenting
C: drive >>%logfile% Echo. >>%logfile% defrag.exe c: -f >>%logfile% Echo
----------------------------------- >>%logfile% Echo Defragmenting E:
drive >>%logfile% Echo. >>%logfile% defrag.exe e: -f >>%logfile% Echo
----------------------------------- >>%logfile% Echo Defragmenting F:
drive >>%logfile% Echo. >>%logfile% defrag.exe f: -f >>%logfile% Echo
----------------------------------- >>%logfile% Echo Finished
%date%,%time% >>%logfile% Echo -----------------------------------
>>%logfile%

Like Defrag.bat, Defrg.bat runs defrag.exe. However, Defrg.bat has a few
more features than Defrag.bat. I included code that documents when the
defragmenter starts and ends in a log file. I also added code that ports
the defragmenter's screen output to the same log file (with some titles
in between) to record which drives are being defragmented. That way, I
can easily check to see whether the defragmentation operation ran and
whether any errors occurred.

To use the new script, I log on to the server with my administrator ID,
open a command-shell window, and run command

at 08:00pm /every:M,T,W,Th,F
f:\Defrg.bat

(Although this command appears on several lines here, you would enter it
on one line in the command-shell window.) This command creates a new
scheduled item in Scheduled Tasks that runs Defrg.bat every weeknight at
8 p.m. (which is before our backup runs).

With this new batch file, I don't need to be logged on for it to run.
Because Defrg.bat is running as a system process, the defragmentation
operation is performed in the background (i.e., no window comes up), but
Task Manager will show that defrag.exe and dfrgntfs.exe are running.
After Defrg.bat finishes, the scheduler will show 0x0 for a successful
execution. However, I always check the log file to make sure no problems
were encountered.

To use Defrg.bat, you simply need to replace f:\defrag.log in the code
at callout A in Listing 2 with the pathname to your log file. The AT
command and batch file work on Windows Server 2003, Windows XP
Professional, and Windows XP Home Edition. I recommend that you make the
batch file a read-only, hidden file. That way, no one can edit it so
that it damages your computers when the scheduled batch runs.


-Daniel L. Gillard



Tim Bolton
148 2nd Street North
Central City Iowa, 52214

Microsoft Certified IT Professional

Blog - Http://timbolton.net/


On Thu, Dec 17, 2009 at 8:19 AM, Shane Williford <xxxxxxxxxxxxxxxx
> wrote:

> Hi all..
>
> I was wondering if you guys had a script or something to run a disk defrag
> sched task via GP. I don’t have GPP implemented yet, so I can’t do it the
> traditional GP way…I’ll need a startup/logon script. L
>
>
>
> Thanks!
>
>
>
> Shane M. Williford
>
> Systems Administrator
>
> VCP, MCSE, MCSA Sec, Sec+, Net+, A+
>
> Mazuma Credit Union
>
> 9300 Troost
>
> Kansas City, MO 64131
>
> xxxxxxxxxxxxxxxx
>
> 816-361-4194 x6012
>
>
>
> ------------------------------
> Notice: The information transmitted in this e-mail may contain confidential
> and/ or legally privileged information intended only for the use of the
> individual(s) named above. Review, use, disclosure, distribution, or
> forwarding of this information by persons or entities other than the
> intended recipient(s) is prohibited by law and may subject them to criminal
> or civil liabilities. Statements and opinion expressed in this e-mail may
> not represent those of Mazuma Credit Union. All e-mail communications
> through Mazuma's corporate email system are subject to archiving and review
> by someone other than the recipient. If you have received this communication
> in error, please notify the sender immediately and delete/destroy any and
> all copies of the original message from any computer or network system.
>


Tim Bolton
shanewillifordUser is Offline

Posts:46

12/17/2009 2:55 PM  
Thanks for the responses. What we’re looking at wanting to do use WoL technology to power up PCs to do maintenance (install MS Updates/Virus Scans/run Defrag). I would like to use GP to run the defrag, so how would I implement the below script using GP?

Thanks!

Shane M. Williford
Systems Administrator
VCP, MCSE, MCSA Sec, Sec+, Net+, A+
Mazuma Credit Union
9300 Troost
Kansas City, MO 64131
xxxxxxxxxxxxxxxx<mailto:xxxxxxxxxxxxxxxx>
816-361-4194 x6012

From: xxxxxxxxxxxxxxxx [mailto:xxxxxxxxxxxxxxxx] On Behalf Of Tim Bolton
Sent: Thursday, December 17, 2009 8:31 AM
To: xxxxxxxxxxxxxxxx
Subject: Re: [gptalk] Sched Task via GP?

Very nice Daniel!

link to mentioned article.

http://windowsitpro.com/article/articleid/95487/automate-the-windows-2003-defragmenter-without-paying-extra.html



Tim Bolton
148 2nd Street North
Central City Iowa, 52214

Microsoft Certified IT Professional

Blog - Http://timbolton.net/

On Thu, Dec 17, 2009 at 8:27 AM, Castillo, Daniel (Directory Services) <xxxxxxxxxxxxxxxx<mailto:xxxxxxxxxxxxxxxx>> wrote:
The following line will make a Scheduled Task called defragTest, which will run if the system is on idle for more than 60 minutes defragmenting the C: drive.
Hope this helps.

schtasks /create /SC ONIDLE /I 60 /TN defragTest /TR "defrag C:"

~D~

From: xxxxxxxxxxxxxxxx<mailto:xxxxxxxxxxxxxxxx> [mailto:xxxxxxxxxxxxxxxx<mailto:xxxxxxxxxxxxxxxx>] On Behalf Of Shane Williford
Sent: Thursday, December 17, 2009 8:19 AM
To: xxxxxxxxxxxxxxxx<mailto:xxxxxxxxxxxxxxxx>
Subject: [gptalk] Sched Task via GP?

Hi all..
I was wondering if you guys had a script or something to run a disk defrag sched task via GP. I don’t have GPP implemented yet, so I can’t do it the traditional GP way…I’ll need a startup/logon script. ☹

Thanks!

Shane M. Williford
Systems Administrator
VCP, MCSE, MCSA Sec, Sec+, Net+, A+
Mazuma Credit Union
9300 Troost
Kansas City, MO 64131
xxxxxxxxxxxxxxxx<mailto:xxxxxxxxxxxxxxxx>
816-361-4194 x6012


________________________________
Notice: The information transmitted in this e-mail may contain confidential and/ or legally privileged information intended only for the use of the individual(s) named above. Review, use, disclosure, distribution, or forwarding of this information by persons or entities other than the intended recipient(s) is prohibited by law and may subject them to criminal or civil liabilities. Statements and opinion expressed in this e-mail may not represent those of Mazuma Credit Union. All e-mail communications through Mazuma's corporate email system are subject to archiving and review by someone other than the recipient. If you have received this communication in error, please notify the sender immediately and delete/destroy any and all copies of the original message from any computer or network system.

You are not authorized to post a reply.
Forums >GPTalk >GPTalk Mailing List > [gptalk] Sched Task via GP?



ActiveForums 3.7

Members

MembershipMembership:
Latest New UserLatest:carmicklec
New TodayNew Today:1
New YesterdayNew Yesterday:1
User CountOverall:1399

People OnlinePeople Online:
VisitorsVisitors:0
MembersMembers:0
TotalTotal:0

Online NowOnline Now:

Ads

Banner Inv
Copyright 2009 by GPOGUY.COM
Terms Of Use